Jump to content

[SOLVED] Code problem.


DeepakJ

Recommended Posts

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.

Link to comment
Share on other sites

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.