Hey all. Here's my script. I know it's probably not the most efficient way to do it but I'm still new to SQL and it works for what I need it to do, except for one issue. I don't want to rewrite the whole script if I can avoid it. The script processes 1 of 2 queries depending on the category passed to the script through a URL and needs to print the relevant information as defined in the case statement of the main switch() statement.
<?
switch($category){
case "requested":
$query = "SELECT * FROM customers, parts WHERE customers.cid = parts.cust_id ORDER BY $sortby";
$result = mysql_query($query);
while($part_info = mysql_fetch_assoc($result)){
if($part_info['rma'] === "no"){
echo "<tr><td valign='top'>".$part_info['description']."</td><td valign='top'><a href=../customers/view-customer.php?cid=".$part_info['cid'].">".$part_info['fname']." ".$part_info['lname']."</a></td></td><td valign='top'><center>".$part_info['qty']."</center></td><td valign='top'>".$part_info['cust_cost']."</td><td valign='top'>".$part_info['requested']."</td>";
switch($part_info['ordered']){
case 0:
echo "<td valign='top'><center><a href='../service/parts-change-status.php?pid=".$part_info['pid']."&ordered=1'><img src='/cstucson/priv/tracker/images/cust_drop.png' width='16' height='16' title='Part Has NOT Been Ordered' border='0'></a></center></td></tr>";
break;
case 1:
echo "<td valign='top'><center><a href='../service/parts-change-status.php?pid=".$part_info['pid']."&ordered=0'><img src='../images/check_mark.gif' width='14' height='16' title='Part Has Been Ordered' border='0'></a></center></td></tr>";
break;
}
}
}
break;
case "rma":
$query = "SELECT * FROM customers, parts WHERE customers.cid = parts.cust_id ORDER BY $sortby";
$result = mysql_query($query);
while($part_info = mysql_fetch_assoc($result)){
if($part_info['rma'] === "yes"){
echo "<tr><td valign='top'>".$part_info['description']."</td><td valign='top'><a href=../customers/view-customer.php?cid=".$part_info['cid'].">".$part_info['fname']." ".$part_info['lname']."</a></td></td><td valign='top'><center>".$part_info['qty']."</center></td><td valign='top'>".$part_info['cust_cost']."</td><td valign='top'>".$part_info['requested']."</td>";
switch($part_info['ordered']){
case 0:
echo "<td valign='top'><center><a href='../service/parts-change-status.php?pid=".$part_info['pid']."&ordered=1'><img src='/cstucson/priv/tracker/images/cust_drop.png' width='16' height='16' title='Part Has NOT Been Ordered' border='0'></a></center></td></tr>";
break;
case 1:
echo "<td valign='top'><center><a href='../service/parts-change-status.php?pid=".$part_info['pid']."&ordered=0'><img src='../images/check_mark.gif' width='14' height='16' title='Part Has Been Ordered' border='0'></a></center></td></tr>";
break;
}
}
}
}
?>
My problem lies in the case "rma": statement. It returns no records even though when I view the structure of my database in SQL or phpMyAdmin I can see the records that have the "yes" in the rma field as required for the case statement. The case "requested" works flawlessly. I hope this makes sense. Thanks in advance!
Ryan