View file Ashop/main.php

File size: 4.34Kb
  1. <?
  2. include "config.inc";
  3. $db = @mysql_connect("localhost", "$databaseuser", "$databasepasswd");
  4. @mysql_select_db("$databasename",$db);
  5. ?>
  6. <html>
  7. <head>
  8. <title><? echo $ashopname ?>
  9. </title>
  10. <script language="JavaScript">
  11. function buyItem(itemno)
  12. {
  13. window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=300, height=50")
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body bgcolor="FFFFFF" text="#000000" link="#000000" alink="#000000" vlink="#000000">
  19. <center>
  20. <p><img src="images/logo.gif"></p>
  21. <table width="95%" border="0" cellspacing="0" cellpadding="5">
  22. <tr>
  23. <td width="20%" valign="top">
  24. <p>
  25. <?
  26. // List categories...
  27. if ($cat) {
  28. $sql="SELECT parentcategoryid from category WHERE categoryid = $cat";
  29. $result = @mysql_query($sql,$db);
  30. $parent = @mysql_result($result, 0, "parentcategoryid");
  31. }
  32. $sql="SELECT categoryid, name FROM category WHERE parentcategoryid = categoryid";
  33. $result = @mysql_query($sql,$db);
  34. for ($i = 0; $i < @mysql_num_rows($result); $i++) {
  35. $categoryname = @mysql_result($result, $i, "name");
  36. $categoryid = @mysql_result($result, $i, "categoryid");
  37. echo "<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$categoryid\">$categoryname</a></font><br>";
  38. if (($categoryid == $cat) || ($categoryid == $parent)) {
  39. $subsql="SELECT categoryid, name FROM category WHERE parentcategoryid = $categoryid AND categoryid != parentcategoryid";
  40. $subresult = @mysql_query($subsql,$db);
  41. for ($j = 0; $j < @mysql_numrows($subresult); $j++) {
  42. $subcategoryname = @mysql_result($subresult, $j, "name");
  43. $subcategoryid = @mysql_result($subresult, $j, "categoryid");
  44. echo "<li><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$subcategoryid\">$subcategoryname</a></font><br>";
  45. }
  46. }
  47. }
  48. ?>
  49. </p>
  50.  
  51. <p>
  52. <table width="100%" border="1" cellspacing="0" cellpadding="5" bordercolor="#235C87">
  53. <tr>
  54. <td height="28">
  55. <form method="post" action="" name="shoppingcart">
  56. <font face="Arial, Helvetica, sans-serif"
  57. size="2"><a href="basket.php">Ваша корзина</a>:</font><br>
  58.  
  59. <?
  60. $subtotal = 0;
  61. $items = explode("&", $basket);
  62. for ($i = 0; $i < count($items)-1; $i++) {
  63.  
  64. // Get the products price from the database...
  65. $sql="SELECT price FROM product WHERE productid=$items[$i]";
  66. $result = @mysql_query("$sql",$db);
  67. if (@mysql_num_rows($result) == 0) {
  68. $price = 0;
  69. } else {
  70. $subtotal += @mysql_result($result, 0, "price");
  71. }
  72. }
  73.  
  74. echo "<input type=\"text\" name=\"total\" size=\"4\" value=\"$subtotal\"> $";
  75.  
  76. ?>
  77.  
  78. </form>
  79. </td>
  80. </tr>
  81. <tr>
  82. <td><font face="Arial, Helvetica, sans-serif" size="2"><a href="checkout.php">
  83. Заказать</a>!</font></td>
  84. </tr>
  85. </table>
  86. </td>
  87. <td valign="top">
  88. <?
  89. // List products belonging to this category...
  90.  
  91. $sql="SELECT product.* from productcategory, product WHERE productcategory.categoryid = $cat AND product.productid = productcategory.productid";
  92. $result = @mysql_query($sql,$db);
  93. for ($i = 0; $i < @mysql_num_rows($result); $i++) {
  94. $productid = @mysql_result($result, $i, "productid");
  95. $productname = @mysql_result($result, $i, "name");
  96. $description = @mysql_result($result, $i, "description");
  97. $price = @mysql_result($result, $i, "price");
  98. echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\" width=\"100%\"><tr><td>
  99. <font face=\"Arial, Helvetica, sans-serif\" color=\"#999999\"><b>$productname</b></font></td></tr>
  100. <tr><td><p><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$description</font></p></td></tr>
  101. <tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b>Цена:</b>
  102. <font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$$price</font></td></tr><tr><td>
  103. <form><input type=\"button\" name=\"buy\" value=\"Добавить в корзину\" onClick=\"buyItem($productid)\">
  104. </form></td></tr></table>";
  105. }
  106. @mysql_close($db);
  107. ?>
  108. </td>
  109. </tr>
  110. </table>
  111. </center>
  112. </body></html>