Thanks for your advice but I tried the global thing and it does not work...
Can I assign a value to a global variable after it has been declared?
Can I make this value replaceable?
Note: I wrote "session();" at the top of the page, but it gives an error...
HERE IS MY CODE
$i=0;
while ($prod = db_fetch_object($qid)) {
$i++;
$id = $prod["id"];
$ref = $prod["reference"];
//HERE STARTS THE CODE TO DETERMINE THE PRICE
if(isset($HTTP_POST_VARS))
{
foreach ($HTTP_POST_VARS as $c=>$v)
{
if($c=="selectName1") {$selectName1=$v;}
if($c=="selectName2") {$selectName2=$v;}
if($c=="selectName3") {$selectName3=$v;}
}
$QueryPrice = "SELECT price FROM price WHERE id=$selectName1 AND id1=$selectName2 AND id2=$selectName3";
$PriceResult = mysql_query($QueryPrice);
while($p = mysql_fetch_array($PriceResult))
{
if($enter1){
$price1 = $p["price"];
}
if($enter2){
$price2 = $p["price"];
}
unset($HTTP_POST_VARS);
}
echo($prod->id);
echo($prod->reference);
if($enter1 && $i=='1') { print"$price1"; }
if($enter2 && $i=='2') { print"$price2"; } (etc...)
//AND HERE IS MY ISSUE:
if($enter2) THEN !($enter1), so $price1 won't appear, even if $enter1 has been submitted before $enter2
In other words, if I submit the first query, I get the price for the 1st product,
but if then i submit the second query, I get the price for the second product
BUT i cannot keep the price of the first one!
I have tried to make $price1 global when submitted, but it just does not work...
maybe i am not using it properly.
?>
<form name=\"formName1\" METHOD=POST>
<select name="selectName1" onChange="show()">
...
</select>
<select name="selectName2">
...
</select>
<select name="selectName3">
...
</select>
<?
print "<input type=\"submit\" value=\"Montrer le prix\" name=\"enter$i\">\n";
?>
</form>
<? } ?>//Here stops the while ($prod = db_fetch_object($qid)) loop
Any idea how to fix it?
Is my approach wrong?