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
https://forums.phpfreaks.com/topic/94772-loop-problems/
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.