Behöver hjälp med en mysql kod.

Visa första olästa
Ämnesverktyg
Visa huvudforum
Visningsalternativ
Oläst 2015-07-07, 15:11 #1
MusikMixenMusikMixen är inte uppkopplad
Bara ett inlägg till!
Reg.datum: Feb 2008
Inlägg: 1 527
Standard 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.

CODE
      // 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 är inte uppkopplad
Oläst 2015-07-07, 15:35 #2
MusikMixenMusikMixen är inte uppkopplad
Bara ett inlägg till!
Reg.datum: Feb 2008
Inlägg: 1 527
Koden i sin helhet.
CODE
   // 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

?>
MusikMixen är inte uppkopplad
Aktiva användare som för närvarande tittar på det här ämnet: 0 (0 medlemmar och 0 gäster)