| | #1 |
| HyperActive Warrior Join Date: 2010
Posts: 111
Thanks: 5
Thanked 4 Times in 4 Posts
|
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 |
| |
| | #2 |
| HyperActive Warrior Join Date: 2010
Posts: 160
Thanks: 11
Thanked 12 Times in 12 Posts
|
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; |
| |
| | #3 |
| HyperActive Warrior Join Date: 2010
Posts: 111
Thanks: 5
Thanked 4 Times in 4 Posts
|
that was a great try. didnt work.
|
| |
| | #4 |
| Web Developer Join Date: 2010 Location: Wisconsin
Posts: 322
Thanks: 2
Thanked 80 Times in 74 Posts
|
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. |
| | |
| |
| | #5 |
| Warrior Member Join Date: 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
Now is it working fine?. Let us know
|
| |
|
| Bookmarks |
| Tags |
| adding, issue, php, post |
| Thread Tools | Search this Thread |
| |