- <?
- include "config.inc";
- $db = @mysql_connect("localhost", "$databaseuser", "$databasepasswd");
- @mysql_select_db("$databasename",$db);
- ?>
- <html>
- <head>
- <title><? echo $ashopname ?>
- </title>
- <script language="JavaScript">
- function buyItem(itemno)
- {
- window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=300, height=50")
- }
- </script>
- </head>
-
- <body bgcolor="FFFFFF" text="#000000" link="#000000" alink="#000000" vlink="#000000">
- <center>
- <p><img src="images/logo.gif"></p>
- <table width="95%" border="0" cellspacing="0" cellpadding="5">
- <tr>
- <td width="20%" valign="top">
- <p>
- <?
- // List categories...
- if ($cat) {
- $sql="SELECT parentcategoryid from category WHERE categoryid = $cat";
- $result = @mysql_query($sql,$db);
- $parent = @mysql_result($result, 0, "parentcategoryid");
- }
- $sql="SELECT categoryid, name FROM category WHERE parentcategoryid = categoryid";
- $result = @mysql_query($sql,$db);
- for ($i = 0; $i < @mysql_num_rows($result); $i++) {
- $categoryname = @mysql_result($result, $i, "name");
- $categoryid = @mysql_result($result, $i, "categoryid");
- echo "<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$categoryid\">$categoryname</a></font><br>";
- if (($categoryid == $cat) || ($categoryid == $parent)) {
- $subsql="SELECT categoryid, name FROM category WHERE parentcategoryid = $categoryid AND categoryid != parentcategoryid";
- $subresult = @mysql_query($subsql,$db);
- for ($j = 0; $j < @mysql_numrows($subresult); $j++) {
- $subcategoryname = @mysql_result($subresult, $j, "name");
- $subcategoryid = @mysql_result($subresult, $j, "categoryid");
- echo "<li><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$subcategoryid\">$subcategoryname</a></font><br>";
- }
- }
- }
- ?>
- </p>
-
- <p>
- <table width="100%" border="1" cellspacing="0" cellpadding="5" bordercolor="#235C87">
- <tr>
- <td height="28">
- <form method="post" action="" name="shoppingcart">
- <font face="Arial, Helvetica, sans-serif"
- size="2"><a href="basket.php">Ваша корзина</a>:</font><br>
-
- <?
- $subtotal = 0;
- $items = explode("&", $basket);
- for ($i = 0; $i < count($items)-1; $i++) {
-
- // Get the products price from the database...
- $sql="SELECT price FROM product WHERE productid=$items[$i]";
- $result = @mysql_query("$sql",$db);
- if (@mysql_num_rows($result) == 0) {
- $price = 0;
- } else {
- $subtotal += @mysql_result($result, 0, "price");
- }
- }
-
- echo "<input type=\"text\" name=\"total\" size=\"4\" value=\"$subtotal\"> $";
-
- ?>
-
- </form>
- </td>
- </tr>
- <tr>
- <td><font face="Arial, Helvetica, sans-serif" size="2"><a href="checkout.php">
- Заказать</a>!</font></td>
- </tr>
- </table>
- </td>
- <td valign="top">
-
- <?
- // List products belonging to this category...
-
- $sql="SELECT product.* from productcategory, product WHERE productcategory.categoryid = $cat AND product.productid = productcategory.productid";
- $result = @mysql_query($sql,$db);
- for ($i = 0; $i < @mysql_num_rows($result); $i++) {
- $productid = @mysql_result($result, $i, "productid");
- $productname = @mysql_result($result, $i, "name");
- $description = @mysql_result($result, $i, "description");
- $price = @mysql_result($result, $i, "price");
- echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\" width=\"100%\"><tr><td>
- <font face=\"Arial, Helvetica, sans-serif\" color=\"#999999\"><b>$productname</b></font></td></tr>
- <tr><td><p><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$description</font></p></td></tr>
- <tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b>Цена:</b>
- <font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$$price</font></td></tr><tr><td>
- <form><input type=\"button\" name=\"buy\" value=\"Добавить в корзину\" onClick=\"buyItem($productid)\">
- </form></td></tr></table>";
- }
- @mysql_close($db);
- ?>
- </td>
- </tr>
- </table>
- </center>
- </body></html>