Jump to content

Louffeman

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by Louffeman

  1. I found out the solution, in fact, it's very simple, like this:<td><?php print($produit['quantity']*$produit['price'])?></td>thank you so much!
  2. I will return tomorrow, it is very night here,thank you very much !
  3. for the script the output is:http://www.hostingpics.net/viewer.php?id=678861php6.jpgso, I think $_SESSION['paniers']is no good
  4. for the script: the output is:http://www.hostingpics.net/viewer.php?id=203614php5.jpg
  5. it is the same after having removed the cookies
  6. how can I delete the cookies ?I have never done it
  7. can you tell me what do it do this line ?$sql=substr($sql, 0, -1).") ORDER BY name ASC";
  8. it is the output,http://www.hostingpics.net/viewer.php?id=491451php4.jpg
  9. now the output is:SELECT * FROM trybase WHERE name IN ('',SELECT * FROM trybase WHERE name IN ('','produits',error the same:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:wampserver32wwwsalevotre_panier.php on line 31
  10. thers' no output:if(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";$sql.=$id.",";foreach($_SESSION['cart'] as $name=>$value) {$sql.="'".$name."',";}the output is http://www.hostingpics.net/viewer.php?id=617578php3.jpgif(isset($_SESSION['paniers'])){$sql="SELECT * FROM trybase WHERE name IN (";$sql.=$id.",";foreach($_SESSION['paniers'] as $name=>$value) {$sql.="'".$name."',";
  11. I have already changed<?phpsession_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?phpprint_r($_SESSION);if(isset($_SESSION['paniers'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['paniers'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><tr><td><?php print $produit['name']; ?></td><td><?php print $produit['price']; ?></td><td><?php print $produit['quantity']; ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity'];?>€</td></tr><?php } ?><?php } ?><?php } ?></table><p><a href="index.php">Home[/url]</p>
  12. but I saw the tutorial is:if(isset($_SESSION['cart'])){
  13. so, now, the error is in the line 29:hile ($produit=mysql_fetch_array($query)){http://www.hostingpics.net/viewer.php?id=178851php2.jpg
  14. yes, this is the panier.php<?phpclass Panier{public $nom;private static $nbPanier = 0;public function __construct($nom){$this->name = $nom;}public function set ($key, $value){$_SESSION['paniers'][$this->nom][$key] = $value;}public function get($key){if(isset($_SESSION['paniers'][$this->nom][$key]))return $_SESSION['paniers'][$this->nom][$key];return null;}public function delet($key){if(isset($_SESSION['paniers'][$this->nom][$key]))unset($_SESSION['paniers'][$this->nom][$key]);}public function getPanier(){if(isset($_SESSION['paniers'][$this->nom]))return $_SESSION['paniers'][$this->nom];return array();}public function clear(){if(isset($_SESSION['paniers'][$this->nom]))unset($_SESSION['paniers'][$this->nom]);}}?>
  15. because I copied this script from a tutorial,so I d'ont know 'cart' is what,can you explain me ? it is a variable ?
  16. the picture shows the array result is correct, the quantity that I put is 2, OKhttp://www.hostingpics.net/viewer.php?id=450536php1.jpg
  17. you can see this picture:it is the resulthttp://www.hostingpics.net/viewer.php?id=540557php.jpgI think it is this line in question,but I d'ont know how to modifier,$sql=substr($sql, 0, -1).") ORDER BY name ASC";
  18. I did as you sais,but it is still the same, no display of the buying object (name, price, quantity and amount)<?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);echo mysql_num_rows($query).'<br>';while ($produit=mysql_fetch_array($query)){?>
  19. it is clear that this part has problem, but the server has no error indication,
  20. it is clear that this part has problem, but the server has no error indication, <?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?>€</td></tr><?php } ?><?php } ?><?php } ?>
  21. after having cancelled this line:<?php foreach($listproduit as $produit) { ?>the result is the same,no display for the buying object (name, price, quantity and amount)
  22. yes, the server have no error, but not the display of the buying object (name, price, quantity and amount)which mean's this part doesn't work:
  23. I didn't put the semicolon in my first script, but it runs well.now I put the semicolon, it change nothing, so I think it's not a problem. for this line, I put serveral places to teste it, the error is always:it mean's the "else" is not necessary, No ? I d'ont know.Parse error: syntax error, unexpected T_ELSE in C:wampserver32wwwsalevotre_panier.php on line 41 <?php } else {?> Also you haven't put a semicolon at the end of these 4 PHP lines:
  24. Hi,I have a shopping cart (first script)below is OK, but when I want to make the calculate(second script) the amount,it indicate the under last line ( <p><a href="index.php">Home[/url]</p), error is: Parse error: syntax error, unexpected $end in C:wampserver32wwwsalevotre_panier.php on line 41I wish someone can help me to modifiy it.first script (it is OK)<?phpsession_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?php foreach($listproduit as $produit) { ?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td></tr><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>second script:session_start();require_once 'panier.php';$panier = new Panier('produits');$listproduit = $panier->getPanier();?><?php if(!$listproduit){?><p> votre panier est vide </p><?php } else {?><table border="1" width="50%"><tr><td>Name</td><td>Price</td><td>Quantity</td><td>Amount</td></tr><?phpif(isset($_SESSION['cart'])){$sql="SELECT * FROM trybase WHERE name IN (";foreach($_SESSION['cart'] as $id =>$value) {$sql.=$id.",";}$sql=substr($sql, 0, -1).") ORDER BY name ASC";$query=mysql_query($sql);while ($produit=mysql_fetch_array($query)){?><?php foreach($listproduit as $produit) { ?><tr><td><?php print $produit['name'] ?></td><td><?php print $produit['price'] ?></td><td><?php print $produit['quantity'] ?></td><td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?></td></tr><?php } ?></table><?php } ?><p><a href="index.php">Home[/url]</p>
×
×
  • Create New...