www.webdeveloper.com
Results 1 to 6 of 6

Thread: display of URL vriables in table format

  1. #1
    Join Date
    Feb 2008
    Posts
    20

    display of URL vriables in table format

    I'm very fresher in PHP...

    i need to grab the variable from the php URL and show it in a table format with 4 columns, as i'm able to pass the variables to the URL on PHP page but i'm not able to echo the same in table format...can anyone please help..its most urgent

    here is the URL on php page:
    http://mydomain.net/quote.php?cmd=_cart&upload=1&business=mymail@domain.net&currency_code=USD&lc=US&item_name_1=EZ-T4C-FS&item_number_1=1&quantity_1=3&size_1=null&amount_1=$299.00&no_shipping_1=0&no_note_1=1&item_name_2 =EZ-S4M-FE&item_number_2=2&quantity_2=1&size_2=null&amount_2=$299.00&no_shipping_2=0&no_note_2=1&item_name_3 =EZ-T4C-FE&item_number_3=3&quantity_3=1&size_3=null&amount_3=$399.00&no_shipping_3=0&no_note_3=1


    All i want to show is:

    Part No. | Price | Quantity | Amount
    EZ-T4C-FS | $299.00 | 3 | $897.00
    EZ-S4M-FE | $299.00 | 3 | $299.00
    ....and so on

    any one please help me with the script

  2. #2
    Join Date
    Oct 2008
    Posts
    150
    Something like this should work:
    PHP Code:
    $num 1;
    echo 
    '<table><tr><th>Part No.</th><th>Price</th><th>Quantity</th><th>Amount</th></tr>';
    while (isset(
    $_GET['item_name_' $num])) {
        echo 
    '<tr><td>'
           
    $_GET['item_name_' $num] . '</td><td>'
           
    $_GET['amount_' $num] . '</td><td>'
           
    $_GET['quantity_' $num] . '</td><td>'
           
    . ($_GET['item_name_' $num] * $_GET['quantity_' $num]) 
           . 
    '</td><td></tr>';
        
    $num++;
    }
    echo 
    '</table>'
    It would be easier to handle the data if it would be submitted as arrays (or an array), however.

    Also, don't neglect user-submitted data security.
    Last edited by Sodbuster; 02-17-2009 at 11:08 PM.

  3. #3
    Join Date
    Feb 2008
    Posts
    20
    Thanks Sodbuster..!!!

    That works like charm.....one more thing i need to fix

    where i show the amount it is not multiplying the quantity and the price and just showing 0(zero)...how can this be fixed

    reply is most appreciated

  4. #4
    Join Date
    Feb 2008
    Posts
    20
    Sodbuster...

    what does this mean...Also, don't neglect user-submitted data security. As i don't know much about PHP ...still i'm tweaking around to fix what i did from javascript passing the variables to PHP page...

    if you could help me fixing these too....i thank you for your support

  5. #5
    Join Date
    Oct 2008
    Posts
    150
    There's a typo in my code that's probably causing the zero result. This line:
    PHP Code:
    . ($_GET['item_name_' $num] * $_GET['quantity_' $num]) 
    should be:
    PHP Code:
    . ($_GET['amount_' $num] * $_GET['quantity_' $num]) 
    As for the security part, I think you can find out more with google (for example, "PHP input security") than I could tell you in a post.

    Hope this helps.

  6. #6
    Join Date
    Feb 2008
    Posts
    20
    still..

    i tried changing the "item_name_" to "amount_" still the amount is showing 0(zero) for me...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles