hi all,
I am getting lost in showing data entered in a form to a confirm page.
I have a form with as many list/menu as the categories existing in the
database. DONE
when user choose the items from the list/menus they are passed on to a
second page where he can check if all data are correct and then send
it. DONE
However on the confirm page the script returns also empty lines of text
for the missing fields. I would like to just have the fields entered by
the user one after each other and not as they were on the first form.
How can I get rid of the empty fields ? ( of course just removing the
<BR> tag is not a solution )
I post the code of both pages below ( only the part of interest )
TIA
Johnny
CONFIRM PAGE
<form name="form1" method="post" action="send.php">
<p>Please check the data u entered</p>
<p>
<input name="hiddenField" type="hidden" value="<?php
foreach ($_POST['field'] as $name=>$value) {
echo nl2br("$value");
}
?>">
<?php
foreach ($_POST['field'] as $name=>$value) {
$split = split("\=", $value);
$pieces = explode("=", $value);
echo nl2br("$pieces[1]<BR>");
}
?>
</p>
<input name="Submit" type="submit" value="PROCEDI >>">
</p>
</form>
FORM PAGE
<form name="form1" method="post" action="confirm.php">
<?php
$cat=mysql_query("SELECT DISTINCT category FROM table ORDER BY
id", $db);
while ($category=mysql_fetch_array($cat)) {
$array_categoy[]=$category["category"];
}
foreach($array_category as $key=>$val) {
$data_link=mysql_query("SELECT * FROM table WHERE
category='$val'",$db);
?>
<?php $label = str_replace ( "_"," ",$val) ; ?>
<p> <?php echo $label; ?></p>
<select name="field[<?php $val ?>]"id="<?php $val ?>">
<option > - - - - - - - - - - - - </option>
<?php
while ($link=mysql_fetch_array($data_link)) {
$description_link= $link["product"];
$id_link = $link["id"];
$code_link = $link["code"];
print "<option value=\"$code_link = $description_link\">
$description_link </option>";
}
?>
</select>
<?php
}
?>
<input name="Submit" type="submit" value="GO ON >>">
</form>