Jump to content

How to reorder id's in mysql using php


digitalrjs

Recommended Posts

I'm trying display id's in a specific order example

 

jack

john

larry

tim

 

When I ad a new person the order is.

 

john

larry

tim

jack

 

Here is the code displaying the order and passing it throught flash.

 

<?
include ("common.php");
$query = "SELECT pid, name, position FROM cn_people WHERE category='2' AND published='1'";

$result = @mysql_query($query);

// If query was okay AND we have at least 1 news item...
if ($result && @mysql_num_rows($result) > 0)
{
// Initialise variable to hold news items    
$name_list = "";
   // For each news item returned from query...
   while($row = mysql_fetch_array($result))
   {
    $name_list .= '<font face="Trebuchet MS"><a href="asfunction:details,'.$row['pid'].'"><b>'.$row['name'].'</b>, '.$row['position'].'</a><br>';
   }

   // Output news items back to Flash
print "&name_list=" . urlencode($name_list) . "&";

}
else
{
   // Tell Flash no news items were found
   print "&name_list=" . urlencode("There are no people with issues.");
}

?>


 

 

How list can I list

 

jack as the first name?

Link to comment
https://forums.phpfreaks.com/topic/121602-how-to-reorder-ids-in-mysql-using-php/
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.