Hi Ronald, Thank you for your Reply.
Your DB structure is exactly how i'd also like to set it out.. it makes perfect sense to me. i also already limit the user to selecting 15 within flash... so no problems there.
However, I am just not able to write such a php file! And isn't it a little hectic on the mysql ?
For example, this is how i Envision it to be when the user saves 15 products to their selection.
It creates a new entry in the Selection table
order table:
orderID (auto int)
email
description
and also then create 15 entires into the Selected table:
selectedID
productID
codeID
orderID
This is very good, but a little too advanced PHP for me. I have never done such a 'looping' technique. Everytime I use php and mysql, it is saving one record at a time.
currently this is how it saves...
<?php
@require_once('database.php');
@require_once('function.php');
if(isset($_POST['varEmail'])) {
$result = saveSelection($_POST['varEmail'], $_POST['varMat0'], $_POST['varMat1'], $_POST['varMat2'], $_POST['varMat3'], $_POST['varMat4'], $_POST['varMat5'], $_POST['varMat6'], $_POST['varMat7'], $_POST['varMat8'], $_POST['varMat9'], $_POST['varMat10'], $_POST['varMat11'], $_POST['varMat12'], $_POST['varMat13'], $_POST['varMat14']);
echo "feedback=success";
}
?>
inside function.php:
function saveSelection($email, $mat0, $mat1, $mat2, $mat3, $mat4, $mat5, $mat6, $mat7, $mat8, $mat9, $mat10, $mat11, $mat12, $mat13, $mat14) {
$sql = "INSERT INTO `selections` (`email` , `mat1` , `mat2` , `mat3` , `mat4` , `mat5` , `mat6` , `mat7` , `mat8` , `mat9` , `mat10` , `mat11` , `mat12` , `mat13` , `mat14` , `mat15`) VALUES ('".$email."', '".$mat0."', '".$mat1."', '".$mat2."', '".$mat3."', '".$mat4."', '".$mat5."', '".$mat6."', '".$mat7."', '".$mat8."', '".$mat9."', '".$mat10."', '".$mat11."', '".$mat12."', '".$mat13."', '".$mat14."')";
$result = mysql_query($sql)
or die(mysql_error());
}
This just one operation, but the nice layout you discuss would actually do 16 saves. And first it would need to save a new orderID, and tell that orderID for the next 15 selections to save.
Do you get what i mean?


?? Probably not

Within flash, I pass the varibales in this way:
function saveSelection() {
var theVariables:URLVariables = new URLVariables();
theVariables.varEmail = MovieClip(parent).globalUserAccount;
for(var i:int=0; i < ThumbArray.length; i++)
{
theVariables["varMat" + i] = ThumbArray[i][0];
}
for(var p=ThumbArray.length; p < 15; p++)
{
theVariables["varMat" + p] = 0
}
var theRequest:URLRequest = new URLRequest();
theRequest.url = "saveSelection.php";
theRequest.method = URLRequestMethod.POST;
theRequest.data = theVariables;
var theLoader:URLLoader = new URLLoader();
theLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
theLoader.addEventListener(Event.COMPLETE, loadCompleteHandler);
theLoader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
theLoader.load(theRequest);
function handleIOError(event:IOErrorEvent):void {
event.target.removeEventListener(IOErrorEvent.IO_ERROR, handleIOError);
}
function loadCompleteHandler(event:Event):void {
MovieClip(root).mcCart.createOrder();
}/
}