Hi,
I'm not very good at PHP so sorry if this is stupid but I have a database with a table called item. I want to retrieve certain items based on specific criteria so I have written this function:
function get_item ($item_no, $supp_id, $cat) {
global $connection;
if ($item_no && !$supp_id && !$cat){
$query = "SELECT *
FROM item
WHERE item_id = $item_no";
}
else if (!$item_no && $supp_id && $cat) {
$query = "SELECT *
FROM item
WHERE supp_id = $supp_id and cat_id = $cat";
}
else if (!$item_no && !$supp_id && $cat) {
$query = "SELECT *
FROM item
WHERE category = $cat";
}
else if (!$item_no && $supp_id && !$cat) {
$query = "SELECT *
FROM item
WHERE supplier = $supp_id";
}
$item_set = mysql_query($query, $connection);
confirm_query($item_set);
return $item_set;
}
I have a php page with this:
$item_no = NULL;
$supp_id = 4;
$cat = 3;
$item_set = get_item($item_no, $supp_id, $cat);
while ($row = mysql_fetch_array($item_set)) {
echo "<h1>".$row['item_name']."</h1><br /> ".$row['description']." <br /> £".$row['price']."<br /><img src='".$row['image']."'></p>";}
All I get is a blank page. No errors but no data either.
Can anyone help, please?
Thanks in advance.