Jump to content

Display items in cart


joinx

Recommended Posts

here is my code but not working...always displaying 0 items in your cart.

//Function to display num of items in cart
function writeCart() {
require_once('../Connections/JaceyConn.php');
$sid = session_id();
mysql_select_db($database_JaceyConn, $JaceyConn);
$sqlnum = "SELECT * from cart where session_id = '$sid'";
$num = mysql_query($sqlnum, $JaceyConn) or die(mysql_error());
$totalRows_num = mysql_num_rows($num);
if ($totalRows_num = 0) {
	return '<p>You have no items in your shopping cart</p>';
} else {
	// Parse the cart session variable
	return '<p align ="center">You have '.$totalRows_num.' item(s) in your shopping cart</p>';
}

Link to comment
https://forums.phpfreaks.com/topic/106332-display-items-in-cart/
Share on other sites

In some pages it is being displayed but some i get this error:

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\Apache2.2\htdocs\Jacey\order.php on line 75

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Apache2.2\htdocs\Jacey\order.php on line 77

 

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.