Jump to content

Random Order


ambo

Recommended Posts

I have a code that calls active users and displays them i was wondering if there was a way to bake the row displayed random

<?

if(!defined('TBL_ACTIVE_USERS')) {

  die("Error processing page");

}

 

$q = "SELECT username FROM ".TBL_ACTIVE_USERS

    ." ORDER BY timestamp DESC,username";

$result = $database->query($q);

/* Error occurred, return given name by default */

$num_rows = mysql_numrows($result);

if(!$result || ($num_rows < 0)){

  echo "Error displaying info";

}

else if($num_rows > 0){

  /* Display active users, with link to their info */

  echo "<table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";

  echo "<tr><td><font size=\"2\">\n";

  for($i=0; $i<$num_rows; $i++){

      $uname = mysql_result($result,$i,"username");

      echo "   <div align=\"center\"><a href=\"profile.php?user=$uname\">"

  ."<img src=\"../image.php?id=$session->username\" width=\"50\" height=\"50\" border=\"0\"/></a><br>"

  ."<a href=\"profile.php?user=$uname\">$uname</a></div>";

  }

  echo "</font></td></tr></table><br>\n";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/142729-random-order/
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.