Jump to content

[SOLVED] Loop not giving me the result I want?


garethhall

Recommended Posts

Hello does anyone here know why my foreach loop is not going through all the photos?

 

<?php
$clientID = checkVars($_SESSION['clientID']);

mysql_select_db($database_admin , $admin);
//==============Select options===================
$SQL_options = "SELECT * FROM options WHERE optionStatus = 'on'";
$rs_options = mysql_query($SQL_options, $admin);


//=======================Create Invoice number and select==========================
$SQL_mkInv = "INSERT INTO invoice (invoiceID, invoiceDate, clientId, invoiceState) VALUES ('', CURDATE(), $clientID, '2')";
//if(mysql_query($SQL_mkInv,$admin)){
//	$invID = mysql_insert_id(); // This is the invoice number
//}

// Select photos from Basket
$SQLBasket = "SELECT * FROM basket WHERE clientId = $clientID";
$rsBasket = mysql_query($SQLBasket, $admin);
while($rwBasket = mysql_fetch_assoc($rsBasket)){
// Insert Date into invoice details table
$phID = $rwBasket['photoId'];
//////////echo "Loop 1<b> ".$phID."</b>";
//############################################################
// If I echo the $phID here i get the all the selected photos from the basket
//############################################################
// Set array to hold options Data from DB Using an array as I have to loop though the DB mutiple times
$print_options = array();
while($rw_options = mysql_fetch_assoc($rs_options)){
	$print_options[] = $rw_options ;
}
foreach($print_options  as $options){
	$theOption = $options['optionID'];
	$postSTR = $phID."qty-".$options['optionID']."opt";
	echo $postSTR."<br>";
	//############################################################
	// If I echo $postSTR I only get the first photo in the loop WHY
	//############################################################
//	if($_POST[$postSTR] >= 1){
		$theQTY = $_POST[$postSTR];// the qty of set photo
	//	echo "photoID ".$phID."--QTY".$theQTY."<br>";// checking result
//		$SQL_insertDetails = "INSERT INTO invoiceDetail (clientId, albumId, photoId, optionId, invoiceId, quantity, dState) VALUES ($clientID, '1','$phID', '$theOption', '$invID', '$theQTY', 'CREATE CONDITION FOR PRINT OR DIGITAL' )";
		/*
		if(mysql_query($SQL_insertDetails, $admin)){
			// Update basket IE remove value that hase been added to the invoice details
			$SQL_delBasket = "DELETE FROM basket WHERE clientId = $clientID AND photoId = '$phID'";
			mysql_query($SQL_delBasket,$admin);
		}
		*/
//	}

}



}

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.