Jump to content


Photo

Major php help **solved**


  • Please log in to reply
No replies to this topic

#1 DataSpy

DataSpy
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 09 October 2006 - 10:29 PM

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 info

Example:

container[0] info:
container = a0
name = jim
city = Kenosha
state = Wisconsin

container[1] info:
container = a1
name = jim
city = Kenosha
state = Wisconsin

container[2] info:
container = a2
name = jim
city = Kenosha
state = Wisconsin

Page 1 - user gives the amount of containers they want
Page 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 information

Here is the code I have so far:

add_booking_1.php
<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>

add_booking_2.php
<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>

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!
add_booking_3.php
<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>

Any help would be greatly appretiated (very very very much), thanx in advance!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users