Sorting record menu
Posted: Mon Feb 07, 2005 5:23 am
Hi,
I have a script which displays the records by "Type", which is the name for that column.
I would like a drop down box to re-sort these by "asset", which is the unique asset number given, so that I can run through everything in order of asset.
Here is the code for the view.php page that shows the records by type;
feyd | help us help you, use the formatting we provide
I have a script which displays the records by "Type", which is the name for that column.
I would like a drop down box to re-sort these by "asset", which is the unique asset number given, so that I can run through everything in order of asset.
Here is the code for the view.php page that shows the records by type;
Code: Select all
<?php
$db = mysql_connect("localhost","giacom-admin","snooker") or die("Problem connecting");
mysql_select_db("audit") or die("Problem selecting database");
$query = "SELECT * FROM dedicated order by type";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
echo "<TABLE BORDER="0" table width="100%">\n";
echo "<TR bgcolor="#cccccc"><TD font colour="red"><b>Asset</b></TD><TD><b>Title</b></TD><TD><b>Customer</b></TD><TD><b>Type</b></TD><TD><b>IP address</b></TD><TD><b>Location</b></TD><TD><b>OS</b></TD><TD><b>OS License</b></TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor="#ffff99">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor="#ffffcc">\n";
}
echo "<TD><font color="red"><b>".$rowї'asset']."</b></font></TD><TD><font size="2">".$rowї'title']."</TD><TD><font size="2">".$rowї'customer']."</TD><TD><font size="2">".$rowї'type']."</TD><TD><font size="2">".$rowї'IP']."</TD><TD><font size="2">".$rowї'location']."</TD><TD><font size="2">".$rowї'os']."</TD><TD><font size="2">".$rowї'oslicense']."</TD>\n";
echo "</TR>\n";
}
//now let's close the table and be done with it
echo "</TABLE>\n";
?>feyd | help us help you, use the formatting we provide