madhuramasamy Posted July 23, 2010 Share Posted July 23, 2010 i would like to have the chemical name arranged in alphabetical order when clicked on the title Chemical name( like a link that would change the order in ascending). but the problem is i get chemical id from chem_inventory and chemical name from chemical acids (2 diff tables) . also count option is used with group by for chemical id . becaz of all this just order by option in statment 11 doesnot work. can someone suggest an alternative? Thanks in advance! <?php include "basic.php"; include "header.php"; include "dbname.php"; dbconnect("","","",""); $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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/208716-arrange-in-alphabetical-order/ Share on other sites More sharing options...
awjudd Posted July 23, 2010 Share Posted July 23, 2010 Why are these split into two queries? You could easily do it all in one I believe. ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/208716-arrange-in-alphabetical-order/#findComment-1090430 Share on other sites More sharing options...
madhuramasamy Posted July 26, 2010 Author Share Posted July 26, 2010 Iam just learning and trying to do. since they are 2 different tables i used separate queries . Quote Link to comment https://forums.phpfreaks.com/topic/208716-arrange-in-alphabetical-order/#findComment-1091375 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.