Jump to content

Major php help **solved**


DataSpy

Recommended Posts

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:

[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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.