Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'wishlist.php'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 2 results

  1. Hello All. The link "Remove from wishlist", on the Wishlist page is not working. i.e, it's not removing item from the Wishlist. It could be the wishlist.html or the wishlist.php (I'm not sure). Here's the code for both. Thank you in advance!! wishlist.html (php part) <?php // Fetch each item: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $price = get_just_price($row['price'], $row['sale_price']); $subtotal = $price * $row['quantity']; echo '<tr> <td>' . $row['category'] . '::' . $row['name'] . '</td> <td align="center"><input type="text" name="quantity[' . $row['sku'] . ']" value="' . $row['quantity'] . '" size="2" class="small" /></td> <td align="right">$' . number_format($price, 2) . '</td> <td align="right">$' . number_format($subtotal, 2) . '</td> <td align="right"><a href="/cart.php?sku=' . $row['sku'] . '&action=move&qty=' . $row['quantity'] .'">Move to Cart</a><br /><a href="/wishlist.php?sku=' . $row['sku'] . '&action=remove">Remove from Wish List</a></td> </tr> '; // Check the stock status: if ( ($row['stock'] > 0) && ($row['stock'] < 10)) { echo '<tr class="error"><td colspan="5" align="center">There are only ' . $row['stock'] . ' left in stock of the ' . $row['name'] . '.</td></tr>'; } } // End of WHILE loop. ?> </table><p align="center"><input type="submit" value="Update Quantities" class="button" /></form></p></div> wishlist.php // If there's a SKU value in the URL, break it down into its parts: if (isset($_GET['sku'])) { list($sp_type, $pid) = parse_sku($_GET['sku']); } if (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the wish list. $r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)"); } elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the wish list. // Determine the quantity: $qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1; // Add it to the wish list: $r = mysqli_query($dbc, "SELECT id FROM carts where user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); if (mysqli_num_rows($r) == 1) { // Exists in cart, UPDATE! list($cid) = mysqli_fetch_array($r, MYSQLI_NUM); $r = mysqli_query($dbc, "UPDATE carts SET quantity=quantity+1, date_modified=NOW() WHERE id=$cid"); } else { // Not in cart, INSERT! $r = mysqli_query($dbc, "INSERT INTO carts (user_session_id, product_type, product_id, quantity) VALUES ('$uid', '$sp_type', $pid, 1)"); } // Remove it from the cart: $r = mysqli_query($dbc, "DELETE FROM carts WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); } elseif (isset($_POST['quantity'])) { // Update quantities in the wish list. // Loop through each item: foreach ($_POST['quantity'] as $sku => $qty) { // Parse the SKU: list($sp_type, $pid) = parse_sku($sku); if (isset($sp_type, $pid)) { // Determine the quantity: $qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1; // Update the quantity in the wish list: if ($qty > 0) { $r = mysqli_query($dbc, "UPDATE carts SET quantity=$qty, date_modified=NOW() WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); } elseif ($qty == 0) { $r = mysqli_query($dbc, "DELETE FROM carts WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); } } // End of FOREACH loop. }// End of main IF. } // Get the wish list contents: $r = mysqli_query($dbc, "SELECT CONCAT('O', ncp.id) AS sku, c.quantity, ncc.category, ncp.name, ncp.price, ncp.stock, sales.price AS sale_price FROM carts AS c INNER JOIN non_coffee_products AS ncp ON c.product_id=ncp.id INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id LEFT OUTER JOIN sales ON (sales.product_id=ncp.id AND sales.product_type='other' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type='other' AND c.user_session_id='$uid' UNION SELECT CONCAT('C', sc.id), c.quantity, gc.category, CONCAT_WS(' - ', s.size, sc.caf_decaf, sc.ground_whole), sc.price, sc.stock, sales.price FROM carts AS c INNER JOIN specific_coffees AS sc ON c.product_id=sc.id INNER JOIN sizes AS s ON s.id=sc.size_id INNER JOIN general_coffees AS gc ON gc.id=sc.general_coffee_id LEFT OUTER JOIN sales ON (sales.product_id=sc.id AND sales.product_type='coffee' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type='coffee' AND c.user_session_id='$uid'"); if (mysqli_num_rows($r) > 0) { // Products to show! include ('./views/wishlist.html'); } else { // Empty cart! include ('./views/emptylist.html'); } // Finish include ('./includes/footer.html'); ?>
  2. Hi guys. Finally at the end of Chapter 10. I have a problem with the wishlist.php. The cart.php works fine, and they are nearly the same. When I transfer stuff to the 'Wishlist', I get this error: Parse error: syntax error, unexpected $end in /hermes/waloraweb004/b1384/moo.laissezfairelondonco/wolfcut.co.uk/wishlist.php on line 110 I have been trying to locate the missing parenthesis error from beginning to end for half a day, so I guess its time to ask for help. I've made sure all the single and double quotations are as they should be, so I don't think its that. The script is from downloads. Only the pathways and stored procedures sections are different. <?php // This file manages the wish list. // This script is begun in Chapter 9. // Require the configuration before any PHP code: require ('./includes/config.inc.php'); // Check for, or create, a user session: if (isset($_COOKIE['SESSION'])) { $uid = $_COOKIE['SESSION']; } else { $uid = md5(uniqid('biped',true)); } // Send the cookie: setcookie('SESSION', $uid, time()+(60*60*24*30)); // Include the header file: $page_title = 'Coffee - Your Wish List'; include ('./includes/header.html'); // Require the database connection: require ('../mysql.inc.php'); // Need the utility functions: include ('./includes/product_functions.inc.php'); // If there's a SKU value in the URL, break it down into its parts: if (isset($_GET['sku'])) { list($sp_type, $pid) = parse_sku($_GET['sku']); } if (isset ($sp_type, $pid, $_GET['action']) && ($_GET['action'] == 'remove') ) { // Remove it from the wish list. $r = mysqli_query($dbc, "CALL remove_from_wish_list('$uid', '$sp_type', $pid)"); } elseif (isset ($sp_type, $pid, $_GET['action'], $_GET['qty']) && ($_GET['action'] == 'move') ) { // Move it to the wish list. // Determine the quantity: $qty = (filter_var($_GET['qty'], FILTER_VALIDATE_INT, array('min_range' => 1))) ? $_GET['qty'] : 1; // Add it to the wish list: $r = mysqli_query($dbc, "SELECT id FROM carts where user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); if (mysqli_num_rows($r) == 1) { // Exists in cart, UPDATE! list($cid) = mysqli_fetch_array($r, MYSQLI_NUM); $r = mysqli_query($dbc, "UPDATE carts SET quantity=quantity+1, date_modified=NOW() WHERE id=$cid"); } else { // Not in cart, INSERT! $r = mysqli_query($dbc, "INSERT INTO carts (user_session_id, product_type, product_id, quantity) VALUES ('$uid', '$sp_type', $pid, 1)"); } // For debugging purposes: if (!$r) echo mysqli_error($dbc); // Remove it from the cart: $r = mysqli_query($dbc, "DELETE FROM carts WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); // For debugging purposes: if (!$r) echo mysqli_error($dbc); } elseif (isset($_POST['quantity'])) { // Update quantities in the wish list. // Loop through each item: foreach ($_POST['quantity'] as $sku => $qty) { // Parse the SKU: list($sp_type, $pid) = parse_sku($sku); if (isset($sp_type, $pid)) { // Determine the quantity: $qty = (filter_var($qty, FILTER_VALIDATE_INT, array('min_range' => 0)) !== false) ? $qty : 1; // Update the quantity in the wish list: if ($qty > 0) { $r = mysqli_query($dbc, "UPDATE carts SET quantity=$qty, date_modified=NOW() WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); } elseif ($qty == 0) { $r = mysqli_query($dbc, "DELETE FROM carts WHERE user_session_id='$uid' AND product_type='$sp_type' AND product_id=$pid"); } } // End of FOREACH loop. }// End of main IF. // Get the wish list contents: $r = mysqli_query($dbc, "SELECT CONCAT('O', ncp.id) AS sku, c.quantity, ncc.category, ncp.name, ncp.price, ncp.stock, sales.price AS sale_price FROM carts AS c INNER JOIN non_coffee_products AS ncp ON c.product_id=ncp.id INNER JOIN non_coffee_categories AS ncc ON ncc.id=ncp.non_coffee_category_id LEFT OUTER JOIN sales ON (sales.product_id=ncp.id AND sales.product_type='other' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type='other' AND c.user_session_id='$uid' UNION SELECT CONCAT('C', sc.id), c.quantity, gc.category, CONCAT_WS(' - ', s.size, sc.caf_decaf, sc.ground_whole), sc.price, sc.stock, sales.price FROM carts AS c INNER JOIN specific_coffees AS sc ON c.product_id=sc.id INNER JOIN sizes AS s ON s.id=sc.size_id INNER JOIN general_coffees AS gc ON gc.id=sc.general_coffee_id LEFT OUTER JOIN sales ON (sales.product_id=sc.id AND sales.product_type='coffee' AND ((NOW() BETWEEN sales.start_date AND sales.end_date) OR (NOW() > sales.start_date AND sales.end_date IS NULL)) ) WHERE c.product_type='coffee' AND c.user_session_id='$uid'"); if (mysqli_num_rows($r) > 0) { // Products to show! include ('./views/wishlist.html'); } else { // Empty cart! include ('./views/emptylist.html'); } // Finish the page: include ('./includes/footer.html'); ?>
×
×
  • Create New...