Posted by "Shaun" on 10/23/05 03:14
Hi,
I have a form on my site with a database driven amount of rooms for a
property - bedrooms, bathrooms and receptions.
For each room there will be a textfield allowing users to enter the x and y
dimensions.
For each room I need to insert the values to the database, however I cant
think of a way to do this. All one can do with php is a foreach on the
$_POST values whereas I need to process two at a time i.e. one insert of the
x and y values per room. Here is the form I have created:
<form action="<?php action=<?php echo $frm['action']; ?>&property_id=<?php
echo $_GET['property_id']; ?>" method="post">
<table>
<tr>
<?php
$i = 1;
while( $i <= $frm["Number_Of_Bedrooms"] ){
?>
<tr>
<td>Bedroom <?php echo $i ?>
<td>X:<input name="bedroom_<?php echo $i ?>_x" type="text" /></td>
<td>Y:<input name="bedroom_<?php echo $i ?>_y" type="text" /></td>
</tr>
<?php
$i++;
}
$i = 1;
while( $i <= $frm["Number_Of_Bathrooms"] ){
?>
<tr>
<td>Bathroom <?php echo $i ?>
<td>X:<input name="bathroom_<?php echo $i ?>_x" type="text" /></td>
<td>Y:<input name="bathroom_<?php echo $i ?>_y" type="text" /></td>
</tr>
<?php
$i++;
}
$i = 1;
while( $i <= $frm["Number_Of_Receptions"] ){
?>
<tr>
<td>Reception <?php echo $i ?>
<td>X:<input name="reception_<?php echo $i ?>_x" type="text" /></td>
<td>Y:<input name="reception_<?php echo $i ?>_y" type="text" /></td>
</tr>
<?php
$i++;
}
?>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="<? echo
$frm["submit_text"]; ?>"></td>
<td> </td>
</tr>
</table>
</form>
[Back to original message]
|