Jump to content

Recommended Posts

Ok what I am trying to do is take the items that are generated from the query below and upon submit add them to my order table in the DB. This sounds easy, but if you look at my code you will notice that before they submit an order they can re-enter in an amount next to their item. Well I need to keep track of each amount entered for each item. I am thinking I will have to use an array, but I am not sure of how to even set it up. As of right now I have it so that if an amount is changed they have to update each item individually before they can hit the final submit button. However, I know there is a way to make it so that all they have to do is enter in an amount next to each item and then hit submit. I also need this for the priority, but once I figure out how to do the amount I will be able to do the priority.

 

<?php
$user_id = $user->inf['id'];
$db->query('SELECT item.id, item.name, guide_order.id, guide_order.amount, guide_order.priority, guide_order.user_id FROM guide_order LEFT JOIN item ON guide_order.item_id = item.id WHERE guide_order.user_id='.$user_id.' ORDER BY guide_order.priority ASC') or die(mysql_error());
$count = $db->num_rows();

if ($count == 0)	{
	echo "<br /><div id='case'><p align='center' style='color: red;'>You have no items for this order to view.</p></div>";
}

if ($count != 0)	{
?>

<style type="text/css">
.menu22 ul{
        margin: 0px; padding: 0px;
        float: left;}

.menu22 ul li{
        display: inline;
	margin:2px 5px 5px 20px;}

</style>

<div class="menu22" align="center">
<table cellpadding='2' cellspacing='2' align='center'>
	<tr>
		<td align='center' style='border-bottom: 1px solid #FFFFFF; padding-right: 20px;'>Quantity</td>
		<td align='center' style='border-bottom: 1px solid #FFFFFF; padding-right: 20px;'>Item</td>
            <td align='center' style='border-bottom: 1px solid #FFFFFF; padding-right: 20px;'>Priority</td>
		<td align='center' style='border-bottom: 1px solid #FFFFFF; padding-right: 20px;'>Delete</td>
	</tr>
<?php


while($row = $db->fetch_array())	{
	?>
		<form id='order_form1' action='' method='post'>
		<input type='hidden' name='pre_id' value='<?=$row['id']?>'/>
				<tr>
				<td align='center'><input type='text' name='amount' size='5' value='<?=$row['amount']?>' /></td>
				<td align='center'><?=$row['name']?></td>
                    <td align='center'><input type='text' name='priority' size='5' value='<?=$row['priority']?>' /></td>
				<td align='center'><input type='submit' name='submit_delete' value='Delete' style="font-size:9px;"/></td>
				</tr>
		</form>

	<?php
}
?><br />
</table>
<form id='order_form' action='' method='post'>
<input type='hidden' name='user_id' value='<?=$user_id?>'/><br />
  Delivery Date:  <input type="text" name="deliver" size="20" /><br /><br />
  <input type='submit' name='submit' value='Submit Order'/>
	</form>

</div>
<?php } ?>

Link to comment
https://forums.phpfreaks.com/topic/131217-php-multiple-updates-on-submit/
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.