I've got a company directory where a basic,
Code: Select all
while($row = mysql_fetch_array( $result )Moderator: General Moderators
Code: Select all
while($row = mysql_fetch_array( $result )Code: Select all
// Example URLs
// http://www.domain.com/list.php?sort=lastname
// http://www.domain.com/list.php?sort=firstname
// http://www.domain.com/list.php?sort=othersort
switch($_GET['sort'])
{
case "lastname":
$result = mysql_query("SELECT * FROM table ORDER BY lastname ASC");
break;
case "firstname":
$result = mysql_query("SELECT * FROM table ORDER BY firstname ASC");
break;
case "othersort":
$result = mysql_query("SELECT * FROM table ORDER BY othersort ASC");
break;
}
// loop through
while($array = mysql_fetch_array($result))
{
//
}Code: Select all
if (isset($_POST['ascarrow'])) {
//query the db with ORDER BY ASC and print the whole table
}
if (isset($_POST['desarow'])) {
//query the db with ORDER BY DES and print the whole table
}