Jump to content

Recommended Posts

Hey guys I need some help for making some things work. This is my index.php and as you can see I have a table of my sql table and a drop list. Now when I press Add to chart on the table on my website, it goes to the cart. But when I select a item from the drop list and click on Add to chart, there only happens an increment of the quantity but the item does not go to the cart.

 

http://fhcs.be/cart-demo2/index.php  this is my website where you can check the problem out. Thanks Guys!!!!

 

<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.php');
// Include functions
require_once('inc/functions.inc.php');
// Start the session
session_start();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP Shopping Cart Demo &#0183; Bookshop</title>
<link rel="stylesheet" href="css/styles.css" />
</head>

<body>

<div id="shoppingcart">

<h1>Your Shopping Cart</h1>

<?php
echo writeShoppingCart();
?>

</div>

<div id="booklist">

<h1>Books In Our Store</h1>

<?php
$sql = 'SELECT * FROM products ORDER BY id';
$result = $db->query($sql);
$output[] = '<ul>';
while ($row = $result->fetch()) {
$output[] = '<li>"'.$row['name'].': €'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>';
}
$output[] = '</ul>';
echo join('',$output);
?>
<?


$Link = mysql_connect("fhcs.be.mysql","fhcs_be","xxxx");
$Query = "SELECT * FROM products";
$DBName = "fhcs_be";
$results = mysql_db_query($DBName, $Query, $Link);



?>
Select a name
<select name = "drop1" size="1">
<Option Value=" ">Select One:</option>
<? //Begins PHP

for($u=0;$u<mysql_num_rows($results); $u++) {
$ID=mysql_result($results,$u,'name');
?>



<option value="<? echo($ID); ?>"><? echo($ID); ?></option><? //Begins PHP
//Begins PHP
}
?>
</select>

<? //Begins PHP
if (mysql_db_query ($DBName, $Query, $Link)) {

}

else {
print ("FAILURE<BR>\n");
}


mysql_close ($Link);




?>


</div>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/225215-need-help-with-php-and-mysql/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.