php - How do I change this to make an if statement for showing up on Paypal -


i having trouble code have. making donation page website , not sure how go part of showing "item_name" part of it. have several options possible donations , show option chose showing in item_name when being redirected pay. have:

        $price = '6.50';     if($_get['prod'] == 1) //price package 1 (regular donator)         $price = '6.50';     if($_get['prod'] == 2) //price package 2 (extreme donator)         $price = '12.50';     if($_get['prod'] == 3) //price package 3 (10 sof spins)         $price = '2.50';     if($_get['prod'] == 4) //price package 4 (20 sof spins)         $price = '4.00';     if($_get['prod'] == 5) //price package 5 (fight kiln completion)         $price = '5.50';     if($_get['prod'] == 6) //price package 6 (1 ragged gold key)         $price = '2.00';     if($_get['prod'] == 7) //price package 7 (4 ragged gold keys)         $price = '9.99';     if($_get['prod'] == 8) //price package 8 (12 ragged gold keys)         $price = '20.00';     if($_get['prod'] == 9) //price package 9 (28 ragged gold keys)         $price = '40.00';    $p->add_field('custom', $_get['username']);   $p->add_field('business', 'dtordik@gmail.com'); //edit email   $p->add_field('return', $this_script.'?action=success');   $p->add_field('cancel_return', $this_script.'?action=cancel');   $p->add_field('notify_url', $this_script.'?action=ipn');   $p->add_field('item_name', 'package '.$_get['prod']);   $p->add_field('item_number', $_get['prod']);   $p->add_field('currency_code', 'usd');   $p->add_field('amount', $price);   //$p->add_field('quantity', $_get['amm']);   $p->add_field('lc', 'gb');   $p->submit_paypal_post(); // submit fields paypal   //$p->dump_fields();      // debugging, output table of fields   break; 

you see $p->add_field('item_name', 'package '.$_get['prod']); grabs number , shows on paypal website "package 1." how can make if chose 'prod' 1, come "regular donator," 'prod' 2 "extreme donator" , on. not know if over-thinking or not appreciated, thank you!

this code bit inefficient, if optimize solution straight forward.

define list of products, price , label.

$products = array(     1 => array(         "price" => "6.00",         "label" => "regular donator"     ),     2 => array(         "price" => "60.00",         "label" => "extreme donator"     ),     3 => array(         "price" => "0.00",         "label" => "cheap bastard"     ) );  $product = $_get["prod"]; $price = $products[$product]["price"]; $label = $products[$product]["label"];  $p->add_field('item_name', $label); $p->add_field('item_number', $product); $p->add_field('amount', $price); // etc 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -