Jump to content

Need Help with php and mysql


andrej13

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

Archived

This topic is now archived and is closed to further replies.

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