Jump to content

Recommended Posts

My code is

 

$query="select Chemical_ID, count(*) from Chem_Inventory where Date_Out=\'0000-00-00\' 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)){

if ($sel[Chemical_ID] >= 1000 && $sel[Chemical_ID] < 2000){ $tbl = "Chemicals_acids";}

if ($sel[Chemical_ID] >= 2000 && $sel[Chemical_ID] < 3000){ $tbl = "Chemicals_solvents";}

if ($sel[Chemical_ID] >= 3000 && $sel[Chemical_ID] < 4000){ $tbl = "Chemicals_metals";}

if ($sel[Chemical_ID] >= 4000 && $sel[Chemical_ID] < 5000){ $tbl = "Chemicals_gases";}

if ($sel[Chemical_ID] >= 5000 && $sel[Chemical_ID] < 6000){ $tbl = "Chemicals_waste";}

$query="select Chemical_Name from $tbl where Chemical_ID = '$sel[Chemical_ID]'";

$chems1 = mysql_query($query);

$chems = mysql_fetch_array($chems1);     

/*print "<tr><td>$sel[iD]</td><td>$sel[Chemical_ID]</td><td>$chems[Chemical_Name]</td><td>$sel</td><td>$sel[Owner]</td><td>$sel[sponsor]</td><td>$sel[Date_In]</td><td>$sel[Date_Out]</td></tr>";}

*/

print "<tr><td>$sel[Chemical_ID]</td><td>$chems[Chemical_Name]</td><td>$sel[count(*)]</td></tr>";}

print "</table>\n";

?>

 

$query="select Chemical_Name from $tbl where Chemical_ID = '$sel[Chemical_ID]'";

 

should be

 

$query="select Chemical_Name from $tbl where Chemical_ID = '{$sel[Chemical_ID]}'";

 

Also any other references to arrays inside strings need to be surrounded by {}

 

print "<tr><td>{$sel[Chemical_ID]}</td><td>$chems[Chemical_Name]</td><td>$sel[count(*)]</td></tr>";}

 

ALSO!

 

Make sure that every reference anywhere in your code that you reference an associative array:

 

array['key']

Use single quotes around the key!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.