Po kliknieciu `add` nie robi nic a powinno dodac np komputer czy tam monitor i po kliknieciu add powinno sie wyswietlic1,2,3,4... itd (wyswietla pusta stronke i adres sie zmienia na http://127.0.0.1/www/cart.php?add=6 z http://127.0.0.1/www/index.php
Robie zgodnie w poradnikiem. Czy ktos widzi blad? Proszę mnie poprawic bo utknąłem ; )

Nie mogę doszukac sie błedu a sprawdzam literka po literce i mam tak samo.




index.php
  1. <?php require 'cart.php'; ?>
  2.  
  3. <html>
  4. <head>
  5.  
  6. </head>
  7. <body>
  8.  
  9. <?php products(); ?>
  10.  
  11. </body>
  12. <html>

cart.php
  1.  
  2. $page = 'index.php';
  3.  
  4. mysql_connect('localhost','root','') or die(mysql_error());
  5.  
  6. if (isset($_GET['add'])) {
  7. $quantity = mysql_query('SELECT id, quantity FROM products WHERE id='.mysql_real_escape_string((int)$_GET['add']));
  8. while ($quantity_row = mysql_fetch_assoc($quantity)) {
  9. if ($quantity_row['quantity']!=$_SESSION['cart_'.$_GET['add']]) {
  10. $_SESSION['cart_'.$_GET['add']]+='1';
  11. }
  12. }
  13. }
  14.  
  15.  
  16. function products() {
  17. $get = mysql_query('SELECT id, name, description, price FROM products WHERE quantity > 0 ORDER BY id DESC');
  18. if (mysql_num_rows($get)==0) {
  19. echo "There are no products to display!";
  20. }
  21. else {
  22. while ($get_row = mysql_fetch_assoc($get)) {
  23. echo '<p>'.$get_row['name'].'<br />'.$get_row['description'].'<br />'.number_format($get_row['price'], 2).' <a href="cart.php?add='.$get_row['id'].'">Add</a></p>';
  24. }
  25. }
  26. }
  27.  
  28. ?>


http://postimage.org/image/onepccixz/
http://postimage.org/image/vf54f77xj/ - podgląd na baze