Jump to content

Loop problems


phpanon

Recommended Posts

Hello,

 

I have a problem with my loop, i think its to do if statement I have at the start because it is going straight to the else statement even when the basket has items in it.

 

Want I want it to do is, if the basket is empty then show " there are no products..."

 

But at the moment it is doing that even when it isn't empty.

 

<?php
require "connect.php";
$empID = $_SESSION['empID'];
$username = $_SESSION['username'];

if($_SESSION['basket'] == !null)
{
	$query =  "insert into orders values ('','".$empID."','".$username."','".date("d-M-Y")."')";
	@mysql_query($query, $connection) or die ("Unable to perform query<br>$query");
	$order_id = mysql_insert_id();

	foreach($_SESSION['basket'] as $key => $product)
	{
		$query2 = "insert into productorder values ($order_id,'".$_SESSION['basket'][$key]['URN']."','".$_SESSION['basket'][$key]['quantity']."','Awaiting Approval')";
		@mysql_query($query2, $connection) or die ("Unable to perform query<br>$query2");
	}
	unset($_SESSION['basket']);
	$message2 = "Order has successfully been submitted";
	header("Location: StationaryBasket.php");
	exit();
}
else
{
	$message1 = "There are no products in the Stationary Basket";
	header("Location: StationaryBasket.php?message1=$message1");
	exit();
}
?>

Link to comment
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.