Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 30th Mar 2011, 06:42 PM   #1
HyperActive Warrior
 
Join Date: 2010
Posts: 111
Thanks: 5
Thanked 4 Times in 4 Posts
Default
php adding to post issue
Share on: 
fb share twitter share gplus share more share

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
layouts4you is offline  
Unread 30th Mar 2011, 07:52 PM   #2
HyperActive Warrior
 
Join Date: 2010
Posts: 160
Thanks: 11
Thanked 12 Times in 12 Posts
Default
Re: php adding to post issue
Share on: 
fb share twitter share gplus share more share

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;
Cash Money Hosting is offline  
Unread 30th Mar 2011, 08:48 PM   #3
HyperActive Warrior
 
Join Date: 2010
Posts: 111
Thanks: 5
Thanked 4 Times in 4 Posts
Default
Re: php adding to post issue
Share on: 
fb share twitter share gplus share more share

that was a great try. didnt work.
layouts4you is offline  
Unread 30th Mar 2011, 10:11 PM   #4
Web Developer
 
Join Date: 2010
Location: Wisconsin
Posts: 322
Thanks: 2
Thanked 80 Times in 74 Posts
Default
Re: php adding to post issue
Share on: 
fb share twitter share gplus share more share

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.

phpbbxpert is offline  
Unread 31st Mar 2011, 06:01 AM   #5
Warrior Member
 
Join Date: 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: php adding to post issue
Share on: 
fb share twitter share gplus share more share

Now is it working fine?. Let us know
theofficialSJ is offline  
Closed Thread


Bookmarks

Tags
adding, issue, php, post


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:24 PM.