Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

script help: inputing multiple form data


gscreations

Recommended Posts

Where am i going wrong with this script, im trying to get all rows of the table into the database:

The form:

<tr>

<td align="right"><?php echo tep_draw_form('delivery', FILENAME_ORDERS, tep_get_all_get_params(array('action')) . 'action=update_delivery'); ?>

<table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr class="dataTableHeadingRow">

<td height="15" colspan="2" class="dataTableHeadingContent"> Delivery Details</td>

<td colspan="2" class="dataTableHeadingContent" align="right">Delivery Charge  </td>

</tr>

<?php

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

echo ' <tr class="dataTableRow">' . "\n" .

' <td>' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n" .

' <td class="dataTableContent" width="50%" align="left">' . $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . "\n" .

' <input type="hidden" name="products_name[0]" value="'. $order->products[$i]['name'] .'">' . "\n" .

' <input type="hidden" name="orders_id[1]" value="'. $oID .'"></td>' . "\n" .

' <td class="dataTableContent" width="50%" align="right">? <input type="text" name="delivery_cost[2]" size="10">' . "\n" .

' </td>' . "\n" .

' <td>' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n" .

' </tr>' . "\n" ;

}

?>

<tr><td colspan="4" align="right"><input type="submit" name="Submit"></td></tr>

<tr><td colspan="4" align="right" class="smallText">Delivery Costs Total: </td></tr>

<tr><td colspan="4" align="right" class="smallText">Order Total: </td></tr>

</table></form></td>

</tr>

 

The Script:

$delivery_data = $HTTP_POST_VARS['delivery_cost'];

for ($i=0, $n=sizeof($delivery_data); $i<$n; $i++) {

$orders_id = tep_db_prepare_input($HTTP_POST_VARS['orders_id']);

$products_name = tep_db_prepare_input($HTTP_POST_VARS['products_name']);

$delivery_cost = tep_db_prepare_input($HTTP_POST_VARS['delivery_cost']);

$insert_sql_data = array('orders_id' => $orders_id,

'products_name' => $products_name,

'delivery_cost' => $delivery_cost);

tep_db_perform(TABLE_DELIVERY_COSTS, array_merge($insert_sql_data));}

Link to comment
Share on other sites

tep_db_perform(TABLE_DELIVERY_COSTS, array_merge($insert_sql_data) inserts the data into the database.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...