Jump to content

s_ainley87

Members
  • Posts

    103
  • Joined

  • Last visited

    Never

Everything posted by s_ainley87

  1. Yeah thanks not got to tidying yet, what i am looking to do is ieterate through an array and pull the deatils from it, and add the deatils to hidden fields of a form...I need to iterate until all products in the session have been looked at.
  2. I dont know what you mean sorry.
  3. Warning: Invalid argument supplied for foreach() in /home/jetexed/public_html/store/basket.php on line 171 } Array ( [cart] => Array ( [79] => Array ( [quantity] => 1 [price] => 49.99 ) [69] => Array ( [quantity] => 1 [price] => 29.99 ) ) ) Warning: Invalid argument supplied for foreach() in /home/jetexed/public_html/store/basket.php on line 171 } Array ( [cart] => Array ( [79] => Array ( [quantity] => 1 [price] => 49.99 ) [69] => Array ( [quantity] => 1 [price] => 29.99 ) ) ) Above are the errors I am getting, I do not understand this.
  4. Hello, Could some one tell me how I could iterate through this array, i need to iterate through the array and every time there is a new product to create the appropiate hidden fields. my current code is this.... <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>JetStore :: Shopping With Jetexed Corporation Ltd</title> <?php require_once ('include/mysql_connect.php'); ?> <link href="CSS/finallayout.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div id="header"> <div align="right" class="headlink"> <a href="index.php">Home</a> | <a href="login.php">Login/Register</a> | <a href="contact.php">Contact Us</a> | <a href="site.php">Site Map</a> </div> </div> <div id="navigation"> <!--Class CURRENT must be changed for each page--> <ul class="jetnav"> <li class="current"><a href="index.php"><b>Home</b></a></li> <li><a href="adobe.php"><b>Adobe Software</b></a></li> <li><a href="microsoft.php"><b>Microsoft Software</b></a></li> <li><a href="security.php"><b>PC Security</b></a></li> <li><a href="digital.php"><b>Digital Photography</b></a></li> <li><a href="mp3.php"><b>Mp3 Players</b></a></li> <li><a href="books.php"><b>Books</b></a></li> </ul> </div> <div id="mainwrapper"> <div id="userlinks"> <div align="center"> <h3>Customer Login</h3> </div> <form name="login" action="processlogin.php" method="post"> <div align="center">Email:<br /> <input type="text" name="username"/> <br /> Password:<br /> <input type="password" name="pword"/> <br /> <input type="submit" value="Login"/> <input type="button" value="Register" onclick="parent.loaction='register.php'"/> </div> </form> <div align="center"> <h3>Customer Links</h3> </div> <p align="center"><a href="deatils.php" target="_self"></a><img src="images/mydetails.gif" width="129" height="45" /></p> <p align="center"><img src="images/mybasket.gif" width="129" height="45" /></p> <p align="center"><img src="images/logmeout.gif" width="129" height="45" /></p> <p align="center"><img src="images/jetexedadvert.jpg" width="200" height="200" /></p> </div> <div id="main"> <h3>Your Basket</h3> <?php //this page dispalys the contents of the shopping basket //this page also lets the user update the contents of their basket // Check if the form has been submitted (to update the cart). if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Change any quantities. foreach ($_POST['qty'] as $k => $v) { // Must be integers! $pid = (int) $k; $qty = (int) $v; if ( $qty == 0 ) { // Delete. unset ($_SESSION['cart'][$pid]); } elseif ( $qty > 0 ) { // Change quantity. $_SESSION['cart'][$pid]['quantity'] = $qty; } } // End of FOREACH. } // End of SUBMITTED IF. // Check if the shopping cart is empty. $empty = TRUE; if (isset ($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; break; // Leave the loop. } } // End of FOREACH. } // End of ISSET IF. // Display the cart if it's not empty. if (!$empty) { require_once ('include/mysql_connect.php'); // Connect to the database. // Retrieve all of the information for the prints in the cart. $query = "SELECT category.category_name, product.product_id, product.product_name FROM category, product WHERE category.category_id = product.category_id AND product.product_id IN ("; foreach ($_SESSION['cart'] as $pid => $value) { $query .= $pid . ','; } $query = substr ($query, 0, -1) . ') ORDER BY product.product_id ASC'; $result = mysql_query ($query, $dbc); // Create a table and a form. echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center"> <tr> <td align="left" width="30%" bgcolor="#FF6600"><b>Category</b></td> <td align="left" width="30%" bgcolor="#FF6600"><b>Product Name</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Price</b></td> <td align="center" width="10%" bgcolor="#FF6600"><b>Qty</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Total Price</b></td> </tr> <form action="basket.php" method="post"> '; // Print each item. $total = 0; // Total cost of the order. while ($row = mysql_fetch_array ($result)) { $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; // Print the row. echo " <tr> <td align=\"left\" bgcolor=\"#cccccc\">{$row['category_name']}</td> <td align=\"left\" bgcolor=\"#cccccc\">{$row['product_name']}</td> <td align=\"right\" bgcolor=\"#cccccc\">£{$_SESSION['cart'][$row['product_id']]['price']}</td> <td align=\"center\" bgcolor=\"#cccccc\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n"; } // End of the WHILE loop. mysql_close($dbc); // Close the database connection. // close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">£' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br />'; ?> <?php } else { echo '<p>Your cart is currently empty.</p>'; } ?> <?php echo"<form id=\"googlecheckout\" method=\"POST\" action = \"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027\" accept-charset=\"utf-8\">"; while ($count > 0) { echo"<input type=\"hidden\" name=\"item_description_$count\" value=\"{$row['category_name']}\" />} <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/>"; $count --; print_r($_SESSION); } echo "<input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"46\" width=\"180\"/> </form>"; echo $row; ?> </div> </div> </div> </body> </html> the array is in a session that look like this } Array ( [cart] => Array ( [79] => Array ( [quantity] => 1 [price] => 49.99 ) [57] => Array ( [quantity] => 1 [price] => 249.99 ) ) ) } Array ( [cart] => Array ( [79] => Array ( [quantity] => 1 [price] => 49.99 ) [57] => Array ( [quantity] => 1 [price] => 249.99 ) ) )[/code=][/code]
  5. the original value is $count = $count+1;
  6. Sorry I am really quite stupid when it comes to PHP, could you explain alittle more please?
  7. Bump..... Please some1 help me :-(
  8. Hello, I am currently creating an online with good intergration for checkoing out, I have assigned variables that are placed into to hidden fields and sent to google, the problem arises when the loop kicks in, as it resets the variables and reassignes them to the old value rather than the next values, // Print each item. $total = 0; // Total cost of the order. while ($row = mysql_fetch_array ($result)) { $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; // Print the row. echo " <tr> <td align=\"left\" bgcolor=\"#cccccc\">{$row['category_name']}</td> <td align=\"left\" bgcolor=\"#cccccc\">{$row['product_name']}</td> <td align=\"right\" bgcolor=\"#cccccc\">£{$_SESSION['cart'][$row['product_id']]['price']}</td> <td align=\"center\" bgcolor=\"#cccccc\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n"; } // End of the WHILE loop. mysql_close($dbc); // Close the database connection. // close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">£' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br />'; ?> <?php } else { echo '<p>Your cart is currently empty.</p>'; } ?> <?php echo"<form id=\"googlecheckout\" method=\"POST\" action = \"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027\" accept-charset=\"utf-8\">"; while ($count > 0) { echo"<input type=\"hidden\" name=\"item_description_$count\" value=\"$catname\" /> <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/>"; $count --; } echo "<input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"46\" width=\"180\"/> </form>"; echo $row; ?> A live version can be here http://www.jetexed.org.uk/store forgive me for the basd coding I am self taught and still learning.
  9. Hello There, I was wondering if some could tell me if it is possible to store data in table that is bullet pointed or a simple way of outputting the data with bullet points? Thank you s_ainley87
  10. Hello, I am making an online store, and I have managed to intergrate the googlecheckout HTML API to work with my PHP cart that I made....the only problem is that the checkout will only process the last item that was added to the cart, i think it may have something to with the loop or one of the variables however my brain is fried I was hoping someone would point me in the right direction? $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; // Print the row. echo " <tr> <td align=\"left\" bgcolor=\"#cccccc\">{$row['category_name']}</td> <td align=\"left\" bgcolor=\"#cccccc\">{$row['product_name']}</td> <td align=\"right\" bgcolor=\"#cccccc\">£{$_SESSION['cart'][$row['product_id']]['price']}</td> <td align=\"center\" bgcolor=\"#cccccc\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n"; // End of the WHILE loop. } mysql_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">£' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br />'; ?> <?php echo "<form id=\"googlecheckout\" method=\"POST\" action = \"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027\" accept-charset=\"utf-8\"> <input type=\"hidden\" name=\"item_description_$count\" value=\"$catname\" /> <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/> <input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"46\" width=\"180\"/> </form>"; } else { echo '<p>Your cart is currently empty.</p>'; } ?> Thank you very much, a stressed s_ainley87
  11. Hi guys, I am currently intergrating a site with google checkout, i have my own php shopping basket from where the products get sent to a hidden form supplied by google, on clicking the google checkout button, it only sends the last products added, I think it has some thing do with the look that it is in. basically a loop contents how many entries are in the cart and then gives the appends that vale to end of all the google hidden field names e.g, item_description_$count represents the first copy of item description, and it should cycle adding new versions of the fields for each product that is there but this not happening, all that happens is that a new product is added and when you check out the new product is only dispalyed. I think it is something wrong with while loop? // Print each item. $total = 0; // Total cost of the order. while ($row = mysql_fetch_array ($result)) { $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; // Print the row. echo " <tr> <td align=\"left\" bgcolor=\"#cccccc\">{$row['category_name']}</td> <td align=\"left\" bgcolor=\"#cccccc\">{$row['product_name']}</td> <td align=\"right\" bgcolor=\"#cccccc\">£{$_SESSION['cart'][$row['product_id']]['price']}</td> <td align=\"center\" bgcolor=\"#cccccc\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n"; // End of the WHILE loop. } mysql_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">£' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br />'; ?> <?php echo "<form id=\"googlecheckout\" method=\"POST\" action = \"https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027\" accept-charset=\"utf-8\"> <input type=\"hidden\" name=\"item_description_$count\" value=\"$catname\" /> <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/> <input type=\"image\" name=\"Google Checkout\" alt=\"Fast checkout through Google\" src=\"http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US\" height=\"46\" width=\"180\"/> </form>"; } else { echo '<p>Your cart is currently empty.</p>'; } any help would be great thanks
  12. Can some advise me on this error, Warning: Invalid argument supplied for foreach() in /home/jetexed/public_html/store/view_cart.php on line 78 this is the code, <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>JetStore :: Shopping With Jetexed Corporation Ltd</title> <link href="CSS/jetstorelayout.css" rel="stylesheet" type="text/css" /> <?php require_once ('include/mysql_connect.php'); ?> </head> <body> <div id="wrapper"> <div id="header"> <img src="images/jetstore_header.gif" alt="Welcome To JetStore"/> </div> <div id="navigation"> <!--Class CURRENT must be changed for each page--> <ul class="jetnav"> <li><a href="index.php"><b>Home</b></a></li> <li><a href="adobe.php"><b>Adobe Software</b></a></li> <li><a href="microsoft.php"><b>Microsoft Software</b></a></li> <li><a href="security.php"><b>PC Security</b></a></li> <li><a href="digital.php"><b>Digital Photography</b></a></li> <li><a href="mp3.php"><b>Mp3 Players</b></a></li> <li><a href="books.php"><b>Books</b></a></li> </ul> </div> <div id="login"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> <!--<form id="loginform" name="login" method="post" action="processlogin.php"> <strong>Email:</strong> <input type="text" name="email" <?php if (isset($_POST['email'])) echo $_POST['email']; ?>/><br /><br /> <strong>Password:</strong> <input type="password" name="password"/><br /> <input type="submit" name="submit" value="Login" /> <input type="button" onClick="parent.location='register.php'" value="Register"> <input type="hidden" name="submitted" value="TRUE" /> </form>--><br /> <hr /> <br /> <h2>User Links</h2><br /> <a href = "details.php" class="links">My Details </a><br /> <a href = "view_cart.php" class="links">My Basket </a><br /> <a href = "checkout.php" class="links">Checkout </a><br /> <a href = "logout.php" class="links">Log Out </a><br /> <a href = "contact.php" class="links">Contact Us </a><br /> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> <div id="main"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> <?php //this page dispalys the contents of the shopping basket //this page also lets the user update the contents of their basket // Check if the form has been submitted (to update the cart). if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Change any quantities. foreach ($_POST['qty'] as $k => $v) { // Must be integers! $pid = (int) $k; $qty = (int) $v; if ( $qty == 0 ) { // Delete. unset ($_SESSION['cart'][$pid]); } elseif ( $qty > 0 ) { // Change quantity. $_SESSION['cart'][$pid]['quantity'] = $qty; } } // End of FOREACH. } // End of SUBMITTED IF. // Check if the shopping cart is empty. $empty = TRUE; if (isset ($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; break; // Leave the loop. } } // End of FOREACH. } // End of ISSET IF. // Display the cart if it's not empty. if (!$empty) { require_once ('include/mysql_connect.php'); // Connect to the database. // Retrieve all of the information for the prints in the cart. $query = "SELECT category.category_name, product.product_id, product.product_name FROM category, product WHERE category.category_id = product.category_id AND product.product_id IN ("; foreach ($_SESSION['cart'] as $pid => $value) { $query .= $pid . ','; } $query = substr ($query, 0, -1) . ') ORDER BY product.product_id ASC'; $result = mysql_query ($query, $dbc); // Create a table and a form. echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center"> <tr> <td align="left" width="30%" bgcolor="#FF6600"><b>Category</b></td> <td align="left" width="30%" bgcolor="#FF6600"><b>Product Name</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Price</b></td> <td align="center" width="10%" bgcolor="#FF6600"><b>Qty</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Total Price</b></td> </tr> '; // Print each item. $total = 0; // Total cost of the order. $count = 0; // Count the position in the basket for google while ($row = mysql_fetch_array ($result)) { // Calculate the total and sub-totals and position $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; ?> <form id="googlecheckout" method="POST" action = "https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027" accept-charset="utf-8"> <?php echo "<form id=\"updatebasket\" action=\"view_cart.php\" method=\"post\"> <tr> <td align=\"left\" bgcolor=\"#cccccc\"> $catname <input type=\"hidden\" name=\"item_description_$count\" value=\"$catname\" /> </td> <td align=\"left\" bgcolor=\"#cccccc\"> $prodname <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> </td> <td align=\"right\" bgcolor=\"#cccccc\"> £$price <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> </td> <td align=\"center\" bgcolor=\"#cccccc\"> <input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value= $quantity /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> </td> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n" ; ?> <input type="image" name="Google Checkout" alt="Fast checkout through Google" src="http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/> </form id="updatebasket"> </form id="googlecheckout"> <?php } // End of the WHILE loop. mysql_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' </table> <form id="update" action="view_cart.php" method="post"> <table> <tr> <td colspan="4" align="right"> <b>Total:<b> </td> <td align="right"> £' . number_format ($total, 2) . ' </td> </tr> <div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </table> </form> </div>'; } else { echo '<p>Your cart is currently empty.</p>'; } //first </table> closes shopping cart table ?> </div> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> <div id="footer"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> </div> </body> </html>
  13. I get this error Warning: Invalid argument supplied for foreach() in /home/jetexed/public_html/store/view_cart.php on line 78
  14. Hello Everyone, I am currently intergrating my website with google checkout, since I have made this work my update cart has stopped working, can anybody see why, any help would be greatly recieved. <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>JetStore :: Shopping With Jetexed Corporation Ltd</title> <link href="CSS/jetstorelayout.css" rel="stylesheet" type="text/css" /> <?php require_once ('include/mysql_connect.php'); ?> </head> <body> <div id="wrapper"> <div id="header"> <img src="images/jetstore_header.gif" alt="Welcome To JetStore"/> </div> <div id="navigation"> <!--Class CURRENT must be changed for each page--> <ul class="jetnav"> <li><a href="index.php"><b>Home</b></a></li> <li><a href="adobe.php"><b>Adobe Software</b></a></li> <li><a href="microsoft.php"><b>Microsoft Software</b></a></li> <li><a href="security.php"><b>PC Security</b></a></li> <li><a href="digital.php"><b>Digital Photography</b></a></li> <li><a href="mp3.php"><b>Mp3 Players</b></a></li> <li><a href="books.php"><b>Books</b></a></li> </ul> </div> <div id="login"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> <!--<form id="loginform" name="login" method="post" action="processlogin.php"> <strong>Email:</strong> <input type="text" name="email" <?php if (isset($_POST['email'])) echo $_POST['email']; ?>/><br /><br /> <strong>Password:</strong> <input type="password" name="password"/><br /> <input type="submit" name="submit" value="Login" /> <input type="button" onClick="parent.location='register.php'" value="Register"> <input type="hidden" name="submitted" value="TRUE" /> </form>--><br /> <hr /> <br /> <h2>User Links</h2><br /> <a href = "details.php" class="links">My Details </a><br /> <a href = "view_cart.php" class="links">My Basket </a><br /> <a href = "checkout.php" class="links">Checkout </a><br /> <a href = "logout.php" class="links">Log Out </a><br /> <a href = "contact.php" class="links">Contact Us </a><br /> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> <div id="main"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> <?php //this page dispalys the contents of the shopping basket //this page also lets the user update the contents of their basket // Check if the form has been submitted (to update the cart). if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Change any quantities. foreach ($_POST['qty'] as $k => $v) { // Must be integers! $pid = (int) $k; $qty = (int) $v; if ( $qty == 0 ) { // Delete. unset ($_SESSION['cart'][$pid]); } elseif ( $qty > 0 ) { // Change quantity. $_SESSION['cart'][$pid]['quantity'] = $qty; } } // End of FOREACH. } // End of SUBMITTED IF. // Check if the shopping cart is empty. $empty = TRUE; if (isset ($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; break; // Leave the loop. } } // End of FOREACH. } // End of ISSET IF. // Display the cart if it's not empty. if (!$empty) { require_once ('include/mysql_connect.php'); // Connect to the database. // Retrieve all of the information for the prints in the cart. $query = "SELECT category.category_name, product.product_id, product.product_name FROM category, product WHERE category.category_id = product.category_id AND product.product_id IN ("; foreach ($_SESSION['cart'] as $pid => $value) { $query .= $pid . ','; } $query = substr ($query, 0, -1) . ') ORDER BY product.product_id ASC'; $result = mysql_query ($query, $dbc); // Create a table and a form. echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center"> <tr> <td align="left" width="30%" bgcolor="#FF6600"><b>Category</b></td> <td align="left" width="30%" bgcolor="#FF6600"><b>Product Name</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Price</b></td> <td align="center" width="10%" bgcolor="#FF6600"><b>Qty</b></td> <td align="right" width="10%" bgcolor="#FF6600"><b>Total Price</b></td> </tr> '; // Print each item. $total = 0; // Total cost of the order. $count = 0; // Count the position in the basket for google while ($row = mysql_fetch_array ($result)) { // Calculate the total and sub-totals and position $count = $count+1; $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; //setting table variables $catname = $row['category_name']; $prodname = $row['product_name']; $price = $_SESSION['cart'][$row['product_id']]['price']; $quantity = $_SESSION['cart'][$row['product_id']]['quantity']; ?> <form id="googlecheckout" method="POST" action = "https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/453070710704027" accept-charset="utf-8"> <?php echo "<tr> <td align=\"left\" bgcolor=\"#cccccc\"> $catname <input type=\"hidden\" name=\"item_description_$count\" value=\"$catname\" /> </td> <td align=\"left\" bgcolor=\"#cccccc\"> $prodname <input type=\"hidden\" name=\"item_name_$count\" value=\"$prodname\" /> </td> <td align=\"right\" bgcolor=\"#cccccc\"> £$price <input type=\"hidden\" name=\"item_price_$count\" value=\"$price\" /> </td> <td align=\"center\" bgcolor=\"#cccccc\"> <input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value= $quantity /> <input type=\"hidden\" name=\"item_quantity_$count\" value=\"$quantity\"/> </td> <input type=\"hidden\" name=\"item_currency_$count\" value=\"GBP\"/> <td align=\"right\" bgcolor=\"#cccccc\">£" . number_format ($subtotal, 2) . "</td> </tr>\n" ; ?> <input type="image" name="Google Checkout" alt="Fast checkout through Google" src="http://checkout.google.com/buttons/checkout.gif?merchant_id=453070710704027&w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/> </form> <?php } // End of the WHILE loop. mysql_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' </table> <form id="update" action="view_cart.php" method="post"> <table> <tr> <td colspan="4" align="right"> <b>Total:<b> </td> <td align="right"> £' . number_format ($total, 2) . ' </td> </tr> <div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </table> </form> </div>'; } else { echo '<p>Your cart is currently empty.</p>'; } //first </table> closes shopping cart table ?> </div> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> <div id="footer"> <div class="rounded"> <div class="top"><div class="right"></div></div> <div class="middle"><div class="right"> <div class="content"> <!--Content Here--> </div> </div></div> <div class="bottom"><div class="right"></div></div> </div> </div> </div> </body> </html>
  15. PayPal would be my choice but the company i am working for have had heated exchanges with PayPal so it is no go, why he cany use a bank gateway i dunno!!! Thank you the link much appreciated.
  16. Thats great, this is just a guess but i assume that the hidden fields that it uses to send it refer to the sessions that hold the cart info? Sorry i dont really understand the google documentation
  17. Ok that is good to know, just got to work through the google documentation now... i presume you can link it to your own shopping cart? havent got that fat that?
  18. I have that information, i was thinking more on the info for bugs and glitches. Google is always my first port of call.
  19. Hi Everyone, I am creating an online shop for a client, and he has specifically asked for me to use google checkout as the method to take payments, i was just wondering if any one had used this checkout on any website, and if they had what was there experience with it, how easy is to intergrate with your own PHP and what not? Thanks
  20. just realised that the add cart code might be helpful too <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>View basket</title> </head> <body> <?php //this page dispalys the contents of the shopping basket //this page also lets the user update the contents of their basket // Check if the form has been submitted (to update the cart). if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Change any quantities. foreach ($_POST['qty'] as $k => $v) { // Must be integers! $pid = (int) $k; $qty = (int) $v; if ( $qty == 0 ) { // Delete. unset ($_SESSION['cart'][$pid]); } elseif ( $qty > 0 ) { // Change quantity. $_SESSION['cart'][$pid]['quantity'] = $qty; } } // End of FOREACH. } // End of SUBMITTED IF. // Check if the shopping cart is empty. $empty = TRUE; if (isset ($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; break; // Leave the loop. } } // End of FOREACH. } // End of ISSET IF. // Display the cart if it's not empty. if (!$empty) { require_once ('include/mysql_connect.php'); // Connect to the database. // Retrieve all of the information for the prints in the cart. $query = "SELECT category_name, product_id, product_name FROM category, product WHERE category.category_id = product.category_id AND product.product_id IN ("; foreach ($_SESSION['cart'] as $pid => $value) { $query .= $pid . ','; } $query = substr ($query, 0, -1) . ') ORDER BY product.product_id ASC'; $result = mysqli_query ($dbc, $query); // Create a table and a form. echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center"> <tr> <td align="left" width="30%"><b>Category</b></td> <td align="left" width="30%"><b>Product Name</b></td> <td align="right" width="10%"><b>Price</b></td> <td align="center" width="10%"><b>Qty</b></td> <td align="right" width="10%"><b>Total Price</b></td> </tr> <form action="view_cart.php" method="post"> '; // Print each item. $total = 0; // Total cost of the order. while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) { // Calculate the total and sub-totals. $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; // Print the row. echo " <tr> <td align=\"left\">{$row['category_name']}</td> <td align=\"left\">{$row['product_name']}</td> <td align=\"right\">\${$_SESSION['cart'][$row['product_id']]['product_price']}</td> <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\">$" . number_format ($subtotal, 2) . "</td> </tr>\n"; } // End of the WHILE loop. mysqli_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">$' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br /><a href="checkout.php"><font size="+2">Checkout</font></a></div>'; } else { echo '<p>Your cart is currently empty.</p>'; } print_r($_SESSION); echo $total; echo $subtotal; ?> </body> </html>
  21. Hello Everyone, I have just made a view shopping cart script for my site but when i add something to the cart then try to view the cart it appears empty i think it might be a problem in the code that i cant see, could someone take a look please? <body> <?php error_reporting(E_ALL); // This page displays the contents of the shopping cart. // This page also lets the user update the contents of the cart. // Check if the form has been submitted (to update the cart). if (isset($_POST['submitted'])) { // Check if the form has been submitted. // Change any quantities. foreach ($_POST['qty'] as $k => $v) { // Must be integers! $pid = (int) $k; $qty = (int) $v; if ( $qty == 0 ) { // Delete. unset ($_SESSION['cart'][$pid]); } elseif ( $qty > 0 ) { // Change quantity. $_SESSION['cart'][$pid]['quantity'] = $qty; } } // End of FOREACH. } // End of SUBMITTED IF. // Check if the shopping cart is empty. $empty = TRUE; if (isset ($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; break; // Leave the loop. } } // End of FOREACH. } // End of ISSET IF. // Display the cart if it's not empty. if (!$empty) { require_once ('include/mysql_connect.php'); // Connect to the database. // Retrieve all of the information for the prints in the cart. $query = "SELECT product_id, category_name, product_name FROM category, product WHERE category.category_id = product.category_id AND product.product_id IN ("; foreach ($_SESSION['cart'] as $pid => $value) { $query .= $pid . ','; } $query = substr ($query, 0, -1) . ') ORDER BY product.product_id ASC'; $result = mysql_query ($query,$dbc); // Create a table and a form. echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center"> <tr> <td align="left" width="30%"><b>Category</b></td> <td align="left" width="30%"><b>Print Name</b></td> <td align="right" width="10%"><b>Price</b></td> <td align="center" width="10%"><b>Qauntity</b></td> <td align="right" width="10%"><b>Total Price</b></td> </tr> <form action="view_cart.php" method="post"> '; // Print each item. $total = 0; // Total cost of the order. while ($row = mysql_fetch_array ($result, MYSQLI_ASSOC)) { // Calculate the total and sub-totals. $subtotal = $_SESSION['cart'][$row['product_id']]['quantity'] * $_SESSION['cart'][$row['product_id']]['price']; $total += $subtotal; // Print the row. echo " <tr> <td align=\"left\">{$row['name']}</td> <td align=\"left\">{$row['product_name']}</td> <td align=\"right\">\${$_SESSION['cart'][$row['product_id']]['price']}</td> <td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty[{$row['product_id']}]\" value=\"{$_SESSION['cart'][$row['product_id']]['quantity']}\" /></td> <td align=\"right\">$" . number_format ($subtotal, 2) . "</td> </tr>\n"; } // End of the WHILE loop. mysql_close($dbc); // Close the database connection. // Print the footer, close the table, and the form. echo ' <tr> <td colspan="4" align="right"><b>Total:<b></td> <td align="right">$' . number_format ($total, 2) . '</td> </tr> </table><div align="center"><input type="submit" name="submit" value="Update My Cart" /> <input type="hidden" name="submitted" value="TRUE" /> </form><br /><br /><a href="checkout.php"><font size="+2">Checkout</font></a></div>'; } else { echo '<p>Your cart is currently empty.</p>'; } ?>
  22. Hello everyone, I have implemented a live search on my website and it is very effective, however some of the strings that can be type in start the same way i.e 'unlocking' i was wondering if there is a away for the results to be trimmed down to say showing the 3 closest matches? This is my code (i presume it is done in the php as this is where the counting is done) <?php $xmlDoc = new DOMDocument(); $xmlDoc->load("products.xml"); $x=$xmlDoc->getElementsByTagName('result'); //get the q parameter from URL $q=$_GET["q"]; //lookup all links from the xml file if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('name'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="Special Order Please Contact Us Directly"; } else { $response=$hint; } //output the response echo $response; ?> Thankyou in advance.
  23. Solved i hadnt closed a previous if how stupid do i look ??? Any way thanks for your suggestions.
  24. Sorry that was unclear i have changed the query on my local host but only changed the code to show line 'whatever' on the forum, sorry for the confusion.
  25. I have tried your above suggestion and it is still not working i am goig mad! :'(
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.