Forum Moderators: coopster
Is there a way to do this? I know I can sort the values like this (this might be somewhat incorrect):
$stop=1;
for($num=1; $stop!=""; $num++) {
$varname1="Name$num";
$varname2="Price$num";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"Name$num\" value=\"${$varname1}\">";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"Price$num\" value=\"${$varname2}\">";
echo " varname1 = ${$varname1} <br>" ;
echo " varname2 = ${$varname2} <br>" ;
$stop = ${$varname1};
}
Basically, How can I have multiple product variables selected by the customer and then sorted and printed out on an order form.
My logic may be a bit off on this - I greatly appreciate any help.
-Bess
would it be something like this for each page with a product on it:
session_start();
$_SESSION['productname' = 'Name of Product on this page';
$_SESSION['productprice' = 'Price of Product on this page';
and then on the form:
session_start();
print '<p> You have selected, ' . ($_SESSION['productname']) . </p>';
Would I use to use a seperate variable for every product to have them all printed out? Such as $_SESSION['productname1', each a unique session id on the product pages? thank you!
-bess
On a form submit store the selected form checkboxes in variables:
if (isset($submit)){
//form is submitted
if (isset($_POST[product1)) {$_SESSION['product1])=$_POST['product1'];
$_SESSION['priceproduct1])=$_POST['priceproduct1'];}
if (isset($_POST[product2)) {$_SESSION['product2])=$_POST['product2'];$_SESSION['priceproduct2])=$_POST['priceproduct2'];}
}
ect.
Perhaps there is a faster way to do this with an array, I am not sure.
And on the checkout page somthing like
if (isset($_SESSION['product1']) {echo 'you ordered '.$_SESSION['product1'];}