Displaying result from a posted form

I’m having trouble showing the outpup of the post variable. The only thing that showing on my confirm.php page is:

For submit, the value is ‘Submit Query’

i’m looking to display the list of books and the quantity inserted in the input box.

Any help would be appreciated.

enter.php

$result = mysql_query("SELECT * FROM test");

echo '<form action ="confirm.php" method="post">';

echo'<p><table border = "1">';

echo'<tr><td>Title</td><td>CD</td><td>Quantity</td></tr>';

while($row = mysql_fetch_array($result)){
	echo '<tr>';
	echo '<td>'. $row['title'] .'</td>';
	echo '<td>'. $row['cd'] .'</td>';
	echo '<td><input type = "text" /></td>';
	echo '</tr>';
}

echo'</table></p>';
echo'<input name="submit" type="submit" />';
echo'</form>';

confirm.php

<?php
      foreach($_POST as $key => $value) {
        echo "<p>For " . $key . ", the value is '" . $value . "'.</p>";
      }
?>

You have no name= attribute for the input type=“text” elements of the form. Try this:

[COLOR=#464646]echo '<td><input type="text" name="cd[]" /></td>';

[/COLOR]

This is what I get when I implement what you suggested:

[I]For cd, the value is ‘Array’.

For submit, the value is ‘Submit Query’.[/I]

Any other ideas on how I could get this working.

Good. I was expecting it to be an array. :slight_smile:

<?php
foreach($_POST as $key => $value) {
    if (is_array($value)) {
        foreach ($value as $idx => $val) {
            echo "<p>For " . $key . "[" . $idx . "], the value is '" . $val . "'.</p>";
        }
    } else {
        echo "<p>For " . $key . ", the value is '" . $value . "'.</p>";
    }
}
?>

print_r($_POST);

Indeed. But I was expanding on the OP’s original request. :wink: And for the output to be in a readable format this is needed …

<pre>
<?php print_r ($_POST); ?>
</pre>