Hi there,
Im trying to make a paypal shop.
I got into the problem.
How can i have this ?
If user select index.php?cat=1
This will show all products from the category.
What i would like to add is, if user type non existing category message the item or cagory doesnt exist in the table .
my script is:
<!-- "srednji red pocinje ovdje shop" -->
<?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="my firm"></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="my firm"></td>
</tr>
<tr>
<td background="prazan/box_left.gif"> </td>
<td width="100%" bgcolor="#6A5B5B"> <p>';
// show the category
if (isset($_GET["cat"]) && $_GET["cat"] > 0) {
$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>";
}
// show the products
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><form method='POST' action='catalog.php?product=$rowp[id]' method='post'><input type='hidden' name='qty' value='1'><input type='submit' class='dno' value='Add to catalogue'></form></td></tr>\n";
}
echo "</table><br>\n";
// if user select one products from the category
}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><form method='POST' action='catalog.php?product=$rowp[id]' method='post'><input type='hidden' name='qty' value='1'><input type='submit' class='dno' value='Add to catalogue'></form></td></tr>\n";
echo "</table><br>\n";
}
// show the introduction to the whow
}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";
}
// show the 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="my firm"></td>
</tr>
<tr>
<td><img name="box_downleft" src="prazan/box_downleft.gif" width="10" height="5" border="0" alt="my firm"></td>
<td background="prazan/box_down.gif"><img name="box_down" src="prazan/box_down.gif" width="79" height="5" border="0" alt="my firm"></td>
<td><img name="box_downright" src="prazan/box_downright.gif" width="6" height="5" border="0" alt="my firm"></td>
</tr>
</table>';
?>