Jump to content

random selection


miltonbanks

Recommended Posts

thanks again for your help, but i cant seem to get it to work, i have managed to print the rows into a table, but cant seem to assign the values to variables

 

$query  = "SELECT * FROM table ORDER BY Rand() LIMIT 5";

  $result = mysql_query($query);

 

 

  echo "<table>";

  while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

      echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";

 

////what i want is $value1=$row[0]  , or something like that

 

  }

  echo "</table>";

} else {

    echo "database down

}

 

?>

 

again, thanks for your time!!!!

Link to comment
https://forums.phpfreaks.com/topic/67715-random-selection/#findComment-340227
Share on other sites

$row[2]

 

$row --- array

[2] ---index of array that is supposedly from your db so

 

syntax should be

 

$row[field of table you query];

 

it should go something like

cho "<tr><td>$row[name]</td><td>$row[add]</td><td>$row[etc]</td></tr>";

 

the example in that site is very clear try to read that again that will help you  ;D ;D

Link to comment
https://forums.phpfreaks.com/topic/67715-random-selection/#findComment-340229
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.