This form for show multiple textbox in form.
<form name="aform" action="test.php" method="post">
<table border="2">
<?php $numberofrow = 5;?>
<?php for($counter = 1;$counter<=$numberofrow;$counter++){ ?>
<tr><td><?php echo $counter; ?></td>
<td><input type="text" name="textfield<?php echo $counter;?>" /></td>
</tr>
<?php }?>
<tr><td><input type="submit" name="Submit" value="submit"/></td></tr>
</table></form>
When you submit the form all textbox data will save in database in multiple row.
<?php
$counter = 5;
mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("te") or die(mysql_error());
$textfield = "textfield";
for ($i = 1; $i <= $counter; $i++) {
$value = $_POST["textfield$i"];
mysql_query("insert into t values('')")or die(mysql_error());
}
?>
No comments:
Post a Comment