Can anyone please help me – I am trying to set a form action variable based on a held value in a mySQL database.
Here is my code to selec the code from the table and then an if/else if statement to set the action variable:
$query = “SELECT code FROM table WHERE name = ‘$name'”;
$result = mysql_query($query) or die (“MySQL error: $query. ” . mysql_error());
while ($myrow = mysql_fetch_array($result)) {
$code = ($myrow[“code”]);
if ($code==”s”)
$action=”sss.php”;
else if ($code==”t”)
$action=”ttt.php”;
}
Then my form HTML code is:
<form action=”<? echo $action; ?>” method=”post”>
This partially works as my form action is always sss.php – even where the code is s or t. Can anyone offer some ideas for me please ??????
Paul