DataSpy Posted October 9, 2006 Share Posted October 9, 2006 I'm trying to take a user defined amount of containers from one page then let the user fill out a text form for each container (there has to be a container# Example="br567"). **this is where I'm stuck** Then on the next page there has to be a query for each container to go into the database with the static infoExample:container[0] info:container = a0name = jimcity = Kenoshastate = Wisconsincontainer[1] info:container = a1name = jimcity = Kenoshastate = Wisconsincontainer[2] info:container = a2name = jimcity = Kenoshastate = WisconsinPage 1 - user gives the amount of containers they wantPage 2 - a form pops up with a text form for each container (the user has to assign a number to each one)Page 3 - for every container there has to be an entry into the database with some other static informationHere is the code I have so far:[b]add_booking_1.php[/b][code]<form action="add_booking_2.php" method="post">Enter the number of containers for this booking. (Example 5)<br><br><input type="text" name="number_of_containers" size="2"><br><br><input type="submit" value="Proceed"></form>[/code][b]add_booking_2.php[/b][code]<form action="add_booking_3.php" method="post"><table border="0" width="100%" cellspacing="4" cellpadding="1"><tr> <td colspan="2" align="center"> <b>Booking Information</b> </td></tr><tr> <td width="55%"> Customer </td> <td align="right"> <input type="text" name="customerid" size="18"> </td></tr><tr> <td> Company </td> <td align="right"> <input type="text" name="companyid" size="18"> </td></tr></tr><?php$number_of_containers=$HTTP_POST_VARS['number_of_containers'];for($i=0; $i < $number_of_containers; $i++){ echo "<tr> <td> Container " .($i+1). " </td> <td align='right'> <input type='text' name='container[$i]' value='Container #' size='18'> </td></tr>";}?><tr> <td colspan="2" align="center"> <input type="submit" value="Enter into DataBase"></form> </td></tr>[/code]This is where the problems begin (at least I think), I also don't know how to get the container values from the previous page and I was thinking of using a for loop for each container to enter into the database. I'm having major problems though![b]add_booking_3.php[/b][code]<tr bgcolor="#F0F8FF"> <td> <?php $customerid=$HTTP_POST_VARS['customerid']; $companyid=$HTTP_POST_VARS['companyid']; $container=$HTTP_POST_VARS['container']; $connection=mysql_connect("localhost", "root", "") or die("Could not establish connection"); mysql_select_db(test, $connection) or die ("Could not select database"); $query="INSERT INTO " . bookings . " VALUES ( '" . $customerid . "', '" . $companyid . "', '" . $container . "')"; $result=mysql_query($query); mysql_close($connection); if ($result){ echo 'Your information has been successfully entered into the database'; } else { echo '<font color="red">Your information could not be entered into the database</font><br>'; } ?> </td></tr>[/code]Any help would be greatly appretiated (very very very much), thanx in advance!!! Link to comment https://forums.phpfreaks.com/topic/23477-major-php-help-solved/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.