DeepakJ Posted July 30, 2007 Share Posted July 30, 2007 Ok I got my code down to this <?php $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $query = "SELECT customerid FROM customerid"; $Result = mysql_query($query); echo "<html><head><title>AlibreCam Verification System</title></head>"; while($row = mysql_fetch_array($Result)){ $alpha = $row['customerid']; echo "<center><TABLE border=0 cellpadding=3><tr><td><center>Customer ID:</center></td> <td><center>".$alpha."</center></td></tr><tr><td><center>Invoice Number:</center></td> <td><center>"; $query2 = "SELECT invoicenum FROM invoiceid WHERE customerid='$alpha'"; $aResult = mysql_query($query2); while($row1=mysql_fetch_array($aResult)){ $invoicenum[]=$row1['invoicenum']; echo $row1['invoicenum']."</center></td></tr><tr><td></td><td><center>"; } echo "</center></td></tr><tr><td><center>Product ID:</center></td> <td><center>"; $counter = 0; foreach($invoicenum as $num => $value){ $query3 = "SELECT * FROM productid WHERE invoicenum = '$value'"; $bResult = mysql_query($query3); while($row2=mysql_fetch_array($bResult)){ $pid = $row2['productid']; $counter = $counter + 1; echo $pid."</center></td></tr><tr><td></td><td><center>"; } } echo "</center></td></tr><tr><td><center>Number of copies bought:</center></td> <td><center>"; $query3 = "SELECT * FROM invoiceid WHERE customerid = '$alpha'"; $cResult = mysql_query($query3); $numoflicenses=0; while($row3=mysql_fetch_array($cResult))( $numoflicenses = $numoflicenses + $row3['numoflicenses'] ); echo $numoflicenses."</center></td></tr><tr><td><center># of licenses remaining:</center></td> <td><center>".$counter."</center></td></tr></table><br>"; } ?> This code works ok except the productids arent' being extracted based on invoicenum. It basically copies the previous customerids productid instead. The same happens with number of licenses remaining. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 NVM I fixed it. Quote Link to comment 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.