![]() |
php adding to post issue Here is the code i have right now. im not sure what im doing wrong. ive tryed a few different things and can not seem to get it working. what i need to do is add a new line to the array at the end of the array. $invoice_number = $_POST['invoice']; $invoice_shipping_query = tep_db_query("SELECT value FROM orders_total WHERE orders_id = '" . $invoice_number . "' and class = 'ot_shipping'"); $invoice_shipping = tep_db_fetch_array($invoice_shipping_query); $shipping_cost = $invoice_shipping['value']; $arrayPost = array_push_assoc($arrayPost, 'shipping', $shipping_cost); any help would be appriciated |
Re: php adding to post issue maybe .... foreach ($_POST as $k=>$v){$posted[$k] = $v;} $invoice_number = $posted['invoice']; $invoice_shipping_query = tep_db_query("SELECT value FROM orders_total WHERE orders_id = '" . $invoice_number . "' and class = 'ot_shipping'"); $invoice_shipping = tep_db_fetch_array($invoice_shipping_query); $shipping_cost = $invoice_shipping['value']; $posted['shipping'] = $shipping_cost; |
Re: php adding to post issue that was a great try. didnt work. |
Re: php adding to post issue First does array_push_assoc() function exist? Its not a built in PHP function. You could just use PHP's array_push() array_push( $shipping_cost, 'shipping'); print_r( $shipping_cost); Will now have shipping added to the array. NOTE: do not assign array_push to a var, its a converter and the assigned var will output a count not the array. To push key => value you would need a function something like this. function array_push_assoc($array, $key, $value){ $array[$key] = $value; return $array; } This pushes the keys also. But the function you are using is using different params In which your first param should result in an undefined variable. So I am not sure what you are trying to do there. |
Re: php adding to post issue Now is it working fine?. Let us know |
| All times are GMT -6. The time now is 02:37 PM. |