Jump to content

Mysql Form Insert


nathan1

Recommended Posts

Hi guys, i have a question about inserting multiple form things...

 

I have a page of permanent orders i want to insert all of the orders into the database of orders, below is the form i have made up for the posted orders;

<form id="add_perms" name="add_perms" method="post" action="">
<?php
$history_result = mysql_query("SELECT * FROM permanant WHERE p_day='monday' ORDER BY cust_id") or die(mysql_error());

while($p_result_ar = mysql_fetch_assoc($history_result)){
?>
<table>
<tr>
<td>
<input type="hidden" value="add_order" name="add_order" id="add_order">
<input type="hidden" value="<?php echo $p_result_ar['p_order']; ?>" name="p_order" id="p_order">
<input type="hidden" value="<?php echo $p_result_ar['order']; ?>" name="p_price" id="p_price">
<input type="hidden" value="<?php echo $p_result_ar['cust_id']; ?>" name="cust_id" id="cust_id">
<b><?php echo $p_result_ar['cust_id']; ?></b> <i>ordered</i> <b><?php echo $p_result_ar['p_order']; ?></b> <i>costing</i> <b><?php echo $p_result_ar['p_price']; ?>.</b>
</td><td>
</td>
</tr>
</table>
<br />
<?php } ?>
</form>

 

Then the insert query;

<?php
if(isset($_POST['add_order'])) {
$put_by = 'permanent_order';
$client =  ($_POST['cust_id']);
$p_day = ($_POST['date]);
$order_p = ($_POST['p_order']);
$p_price = ($_POST['p_price']);

$query = "INSERT INTO orders (client, put_by, date_p, p_order, debit) VALUES ('$client', '$put_by', '$p_day', '$p_order','-$p_price')";
   $result = mysql_query($query) or die(mysql_error());
}
?>

 

Just not sure how to go about this, any help would be appreciated, thank-you

Link to comment
https://forums.phpfreaks.com/topic/103408-mysql-form-insert/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.