Jump to content

Recommended Posts

I have a query that I get results to one at a time depending on the last created item, but would like the results to display in a row separted by a comma. Is this possible?

 

Here is my current code:

$query = "SELECT title FROM XXXXX_XXXXX WHERE private='n' ORDER BY starts DESC LIMIT ".$SETTINGS['lastitemsnumber'];
$result = mysql_query($query);	  
if($result) {
 $num_auction = mysql_num_rows($result);
 $title = mysql_result($result,$i,"title");
    $i++;
}

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/153406-solved-sql-result-array-help/
Share on other sites

Like this?

 

$query = "SELECT title FROM XXXXX_XXXXX WHERE private='n' ORDER BY starts DESC LIMIT ".$SETTINGS['lastitemsnumber'];
   $result = mysql_query($query) or die(mysql_error());    
if($result) {
   while($row = mysql_fetch_assoc($result)) {
      $string .= $row['title'] . " ,";
   }
}

echo $string;

Your on the right track, except I get the result with a , like I want, but not the first result. I will use the word "sample" as array for all result:

 

resulst: samplesample, sample, sample, sample and so on.

 

The first two sample's don't get a , or space.

 

 

Any ideas?

You lead me on the right path!

 

Here we go:

 

$query = "SELECT title FROM PHPAUCTION_auctions WHERE closed='0' AND suspended=0 AND private='n' ORDER BY RAND()";
$result = mysql_query($query);	  
if($result) {
   while($row = mysql_fetch_assoc($result)) {
     $title .= ", ".$row['title'];
}
} 

 

Thanks!

 

Your Awsome! ;D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.