Hi cracker,
It can be done.
The first thing you will need to do is to setup an actual form for your form elements. If you are using html5, this would be something like:[php][/php]
While this should work with other doctypes, HTML5 makes the action attribute optional. Using HTML4, the action attribute is required - in addition, it cannot be empty, so you would need to set the current page as the action in these cases. Many on here and elsewhere will tell you to use a blank action, but this is not correct. It will likely work; however, it is not valid markup and should be avoided. In HTML4 it would look like this:[php][/php]
You will need a submit button:[php][/php]
And you will need to add a form end tag as well. This is simply:[php][/php]
Next, you will need to assign a type and name for each of your inputs. Since you are going to have multiple rows, you will need to add the array indicator to the name. For example, your first input might be:[php]<input type=“text” name=“ordernum[]” value="<?php echo $row_Orders['OrderNumber']; ?>[/php]
The above example will not quite work for your scenario because a blank entry in one of the inputs will throw everything off in your arrays. You will need to specifically index each iteration in order to guarantee that the fields will all be correct after posting. I will demonstrate this below.
Depending on how many rows you will be displaying, you may run into a problem with too large a post on submitting your form. If this happens, you will need to consider different options; let me know and I’ll try to help you find the right one.
You are using a lot of depreciated elements. In addition, there is no reason to use both a table and divs for your data presentation; you should pick one or the other. Many people will tell you that you should never use tables, but this is a valid place for one and I would go ahead and use the table element here. You should also be using css for most of the styles. I will also demonstrate this below.
For testing purposes, here is a mockup to try: on submission, this will display all the contents of your $_POST. This is merely to help determine that everything is being sent on submit and to help you identify each element. The example is presented in html5. One final note: You will need to include your database connect code, it is left out of this example.[php]
Orders Review
.ac {
text-align: center;
}
.al {
text-align: left;
}
.ordnum {
width: 20px;
}
<?php
if(isset($_POST['submit']))
{
// INSERT YOUR PROCESSING CODE HERE
echo '
';
print_r($_POST);
}
?>
Order No. |
Order Date |
Required Date |
Code |
CUSTOMER |
Part |
Description |
Qty |
Freight |
Supplier |
<?php
$i=0;
do {
echo '
|
|
|
|
|
|
|
|
|
|
';
$i++;
} while ($row_Orders = mysql_fetch_assoc($Orders)); ?>
[/php]
While I believe the code above is correct, I did not test it with actual data, as this would have required setting up a test database and inserting several lines. Hopefully it will give you a good start. Once you look it over let me know any questions you have or problems you encounter.
Best,
jay