Hi,I am trying to use POST variables in side a loop, but for some reason, the post data isnt being populated in side my loop but if i echo it before the for loop it is.
Here is an example out put.
[code=php]Array
(
[product1] => 5mm clear toughened glass
[id1] => 134
[width1] => 1000
[height1] => 1000
[price1] => 165.28
[supply1] => supply1
[quantity1] => 1
[Polished_Edges] => 58
[Bevelled_Edges] => 88
[Fixing_Holes] => 26
[Painting] => 168
[powerpoints] =>
[Sandblasting] => 42
[corners] => 40.00
[subtotal2] => 587.28
[gst2] => 73.41
[total2] => 660.69
)
INSERT INTO gm_temp (id,
sid,
prod_id,
prod_name,
dateset,
width,
height,
quantity,
supply,
sundries1,
sundries2,
sundries3,
sundries4,
sundries5,
sundries6,
sundries7,
subtotal)
VALUES (”,
‘3hhq3bb69pmmeo9c8ucphsoqk2′,
”,
”,
’03/05/06-16:25:28’,
”,
”,
”,
”,
”,
”,
”,
”,
”,
”,
”,
”)
and here is the code that is generating it.
[code=php]
<?php
//error_reporting(E_ALL);
ob_start(“ob_gzhandler”);
session_start();
$sid = session_id();
echo($sid);
setlocale(LC_MONETARY, ‘en_NZ’);
include(‘common/header.php’);
include(‘common/connect.php’);
include(“common/functions.php”);
$dateset = date(“d/m/y-H:i:s”);
echo “<pre>”;
print_r($_POST);
echo “</pre>”;
for ($i=0; $i<7;$i++)
{
if (isset($_POST[“product$i”])) {
$query = “INSERT INTO gm_temp (id,
sid,
prod_id,
prod_name,
dateset,
width,
height,
quantity,
supply,
sundries1,
sundries2,
sundries3,
sundries4,
sundries5,
sundries6,
sundries7,
subtotal)
VALUES (”,
‘”.$sid.”‘,
‘”.$_POST[‘id$i’].”‘,
‘”.$_POST[‘product$i’].”‘,
‘”.$dateset.”‘,
‘”.$_POST[‘width$i’].”‘,
‘”.$_POST[‘height$i’].”‘,
‘”.$_POST[‘quantity$i’].”‘,
‘”.$_POST[‘supply$i’].”‘,
‘”.$_POST[‘sundries1$i’].”‘,
‘”.$_POST[‘sundries2$i’].”‘,
‘”.$_POST[‘sundries3$i’].”‘,
‘”.$_POST[‘sundries4$i’].”‘,
‘”.$_POST[‘sundries5$i’].”‘,
‘”.$_POST[‘sundries6$i’].”‘,
‘”.$_POST[‘sundries$i’].”‘,
‘”.$_POST[‘subtotal’].”‘)”;
$result = mysql_query($query);
if(!$result){
echo(“not added in to the temp db:<br />”.mysql_error().”<br />”.”r”.”<hr />”);
}
}
}
echo “<pre>”;
print_r($query);
echo “</pre>”;
//header(“Location: cart.php”);
?>