$_POST-ing numeric variables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a program that is getting variables from a table and displaying
them through a loop. However, when I want to post the variables to
another form, the number variable seems to only pass the max. Here is
a sketch of the program:


<?php do { ?>
<form name="form1" id="form1" method="post" action="frm2.php">

<input type="hidden" name="hosp_no" value=<?php echo $text_variable; ?
Quoted text here. Click to load it
<input type="hidden" name="ctr" value=<?php echo
$row_zz['number_variable']; ?>

<?php } while ($row = mysql_fetch_assoc($qry)); ?>


In frm2, the text_variables all come but the numeber variables only
show the highest number. Please F1.

Re: $_POST-ing numeric variables

Quoted text here. Click to load it

Either add [] after the input name, or [<some_unique_identifier>]  (in  =

which a primary key from the table would be best suited if available.  =

Also, validate your HTML, you don't want to star N number of forms, and =

close it with a single tag.....

<form name=3D"form1" id=3D"form1" method=3D"post" action=3D"frm2.php">
<input type=3D"hidden" name=3D"hosp_no" value=3D"<?php echo  =

htmlspecialchars($text_variable); ?>">
while($row = mysql_fetch_assoc($qry)){
    printf('<input type=3D"hidden" name=3D"ctr[%d]" value=3D"%s">', $row['i=
d'],  =

htmlspecialchars( $row['number_variable'] );
    printf('<input type=3D"hidden" name=3D"ctr[]" value=3D"%s">',  =

htmlspecialchars( $row['number_variable'] );*/
-- =

Rik Wasmus

Site Timeline