Hello,
I am try ing to compare two tables in my Database and list them all out and checking the one that are common. This is wha I have so far.
<?php
echo "<table border=1>\n";
echo "<tr><td><b>Assigned</b><td><b>BPCS Number</b></td><td><b>Customer</b></td><td><b>Model year</b></td><td><b>Program</b></td></tr>\n";
$db = mysql_connect("localhost", "user", "pswd");
$result1 = mysql_db_query("cad_design_db", "SELECT b.bpcs_num, b.model_year, b.program_name, c.comp_name FROM bpcs b, customers c where b.cust_id = c.cust_id order by comp_name");
$result2 = mysql_db_query("cad_design_db", "SELECT bpcs_num FROM bpcs_assn WHERE cadsource_id = 6");
$row2 = mysql_fetch_object($result2);
while($row1 = mysql_fetch_object($result1)) {
if ($row2->bpcs_num == $row1->bpcs_num)
{
$checked="checked";
}
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</tr>\n", "<input type=\"checkbox\" name=\"$row1->bpcs_num\" value=\"$row1->bpcs_num\" $checked>", $row1->bpcs_num, $row1->comp_name, $row1->model_year, $row1->program_name);
unset($checked);
}
mysql_free_result($result1);
?>
This does everything that I am looking to do so far except it only checks the first common field. So I only get one checked.
Any thoughts?
Thanks