hi there,
i have a problem with my shopping cart.
if user type in browser window: index.php?cat=1 , its just fine.
but when you type like this: index.php?cat=
cat not set !
i get error that i have error in code.
<!-- " shop starts here" -->
<?php
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="0"><img name="box_upleft" src="prazan/box_upleft.gif" width="10" height="30" border="0" alt=""></td>
<td width="94%" align="center" valign="middle" background="prazan/box_r1_c2.gif"><div align="left"></div></td>
<td width="0"><img name="box_upright" src="prazan/box_upright.gif" width="6" height="30" border="0" alt=""></td>
</tr>
<tr>
<td background="prazan/box_left.gif"> </td>
<td width="100%" bgcolor="#6A5B5B"> <p>';
// we set cat
if (isset($_GET['cat'])){
//query products table
$queryp=mysql_query("Select * from products where category='$_GET[cat]'");
echo "<table width=100%>\n";
$query = "SELECT * from categories WHERE id = $cat";
$mysqlresult = mysql_query($query);
while($row = mysql_fetch_array($mysqlresult)){
echo "<tr><td class='nazivlinka'> $row[name]</td></tr>";
}
echo "<tr><td >Product picture</td><td ><div>Product Name</div></td><td ><div>Price</div></td><td ><div>Buy it</div></td></tr>";
while ($rowp=mysql_fetch_array($queryp)){
echo "<tr><td align='left'> <a href='index.php?product=$rowp[id]'><img src='shop/images/$rowp[photo]' border=0></a></td>";
echo "<td>$rowp[name]</td><td>$rowp[price]</td><td><a href='catalog.php?product=$rowp[id]'>Add to Catalog</a></td></tr>\n";
}
echo "</table><br>\n";
}elseif(isset($_GET['product'])){
$queryp=mysql_query("Select * from products where id='$_GET[product]'");
while ($rowp=mysql_fetch_array($queryp)){
echo "<table width=100% >\n";
echo "<tr ><td width=70%><div>$rowp[name]</div></td><td><div>$$rowp[price]</div></td></tr>";
echo "<tr><td rowspan=2 valign='top'>$rowp[description]</td><td><a href='/$rowp[photobig]' target='_blank'><img src='shop/images/$rowp[photo]' border=0><br>Click to Enlarge</a></td></tr>";
echo "<tr><td><a href='catalog.php?product=$rowp[id]'>Add to Catalog</a></td></tr>\n";
echo "</table><br>\n";
}
// display welcome note
}else{
$queryw=mysql_query("Select * from setup where id=1");
echo "<table width=100% ><tr >\n";
while ($roww=mysql_fetch_array($queryw)){
$welco=nl2br(stripslashes($roww['welcome']));
echo "<tr><td><div class='ttitle1'>$roww[store]</div></td></tr><tr>";
echo "<td > $welco</td></tr>";
}
echo "</table><br>\n";
}
// display featured product
$queryp=mysql_query("Select * from products order by rand() limit 0,3");
echo "<table width=100%><tr >\n";
echo "<tr><td colspan=3 ><div>Featured Products</div><hr></td></tr><tr>";
while ($rowp=mysql_fetch_array($queryp)){
echo "<td align='center' width=33%> <a href='index.php?product=$rowp[id]'><img src='shop/images/$rowp[photo]' border=0></a>";
echo "<br>$rowp[name]<br>$$rowp[price]</td>\n";
}
echo "</tr></table><br>\n";
echo ' </p></td>
<td background="prazan/box_right.gif"><img name="box_right" src="prazan/box_right.gif" width="6" height="48" border="0" alt=""></td>
</tr>
<tr>
<td><img name="box_downleft" src="prazan/box_downleft.gif" width="10" height="5" border="0" alt=""></td>
<td background="prazan/box_down.gif"><img name="box_down" src="prazan/box_down.gif" width="79" height="5" border="0" alt=""></td>
<td><img name="box_downright" src="prazan/box_downright.gif" width="6" height="5" border="0" alt=""></td>
</tr>
</table>';
?>
<!-- "shop ens here" -->
is there any way i could give user error, that id doesnt exist, or not choosen.
thank you for your help.