WN

WN (https://www.wn.se/forum/index.php)
-   Serversidans teknologier (https://www.wn.se/forum/forumdisplay.php?f=4)
-   -   Behöver hjälp med en mysql kod. (https://www.wn.se/forum/showthread.php?t=1065167)

MusikMixen 2015-07-07 14:11

Behöver hjälp med en mysql kod.
 
Har googlat som en galning men fattar inte hur jag ska få allt till en kodsträng.

Kod:

      // Build Sql that returns the data needed - change this as required. 
      $sql = "SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime, songlist.picture as picture FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 1";
      $sql = "SELECT songlist.*, queuelist.requestID as requestID FROM queuelist, songlist WHERE (queuelist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY queuelist.sortID ASC");
      $sql = "SELECT * FROM requestlist WHERE (ID = '$requestID') LIMIT 1");

Hur får jag den koden, att bli bara en sträng, alltså en rad?
jag vill plocka ut picture, Artist, Title, Name, Msg så hälsningen och namnet på dne som önskat låten visas när låten spelas.

Tacksam för hjälp!

MusikMixen 2015-07-07 14:35

Koden i sin helhet.
Kod:

  // Connect to the database 
  $link = mysql_connect('localhost',$username,$password);
  mysql_set_charset('utf8',$link);

  // Handle an error
  @mysql_select_db($database) or die( "Unable to select database");



      // Build Sql that returns the data needed - change this as required. 
      $sql = "SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime, songlist.picture as picture FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 1";

      // Store results in result object
      $result = mysql_query($sql);
     
      //store values in vars for calculation for array creation
      $dt_played = mysql_result($result,$i,'date_played');
      $dt_duration = mysql_result($result,$i,'duration');
      $title= mysql_result($result,$i,'title');
      $artist= mysql_result($result,$i,'artist');
      $name= mysql_result($result,$i,'name');
      $msg= mysql_result($result,$i,'msg');
      $picture= rawurlencode(mysql_result($result,$i,'picture'));
      $starttime = strtotime($dt_played);
      $curtime = time();
      $timeleft = $starttime+round($dt_duration/1000)-$curtime;
      $secsRemain = (round($dt_duration / 1000)-($curtime-$starttime));

     
      //build array to return via getXMLHTTPRequest object - you can include more vars but remeber to handle them
      //correcty in the useHttpResponse function     
      $Aj_array = $dt_duration . '|' . $secsRemain . '|' . $title . '|' . $artist .'|' . $name . '|' . $msg .'|' . $picture;

     
      //we are using the text response object  - which i think is easier for small data return
      //just echo the array                - not so much AJAX rather AJA ??
      echo $Aj_array

?>



Alla tider är GMT +2. Klockan är nu 02:20.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson