Jump to content

alphabetical order arrangement


madhuramasamy

Recommended Posts

I want to arrange the chemical name in alphabetical order when clicked on the title 'chemical name' in the php file.. can some one look at the code and tell me what shuld be done ?

 

Thanks in advance!

 

<?php
include "basic.php";
include "header.php";
include "dbname.php";
dbconnect("MICROLAB","MICROLAB","Charles1","web6.duc.auburn.edu");
$query="select Chemical_ID, count(Chemical_ID) as Available from Chem_Inventory where Date_Out='0000-00-00' and (Chemical_ID>=1000 and Chemical_ID<2000) group by Chemical_ID ";
$result=mysql_query($query);
print "<h3><p><center>Microlab Chemical Inventory</center></p></h3><br>";         
print "<table><tr><td><b>Chemical ID</td><td><b>Chemical Name</td><td><b>Available Stock</td></tr>";
while ($sel = mysql_fetch_array($result)){
$query="select Chemical_Name from Chemicals_acids where Chemical_ID = '$sel[Chemical_ID]'";
$chems1 = mysql_query($query);
$chems = mysql_fetch_array($chems1);       
print "<tr><td>$sel[Chemical_ID]</td><td>$chems[Chemical_Name]</td><td>$sel[Available]</td></tr>";}
print "</table>\n";
print "<p><A href=\"search1.php\">Back</A></P>\n";
?>

Link to comment
https://forums.phpfreaks.com/topic/208675-alphabetical-order-arrangement/
Share on other sites

Add an ORDER BY chemical_name_field_here ASC to the query that needs to be sorted.

 

And now that you've posted your database connection credentials on the internet, you might want to change the username and password on the server . . .

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.