Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP SELECT Where Clause with multiple requests

    This is the code i am working with:
    Code:
    <?php
    
    //$result = mysql_query("SELECT * FROM zen_orders Where orders_id=".$_GET['order_id']);
    $sql = "SELECT * FROM zen_orders_total Where orders_id=".$_GET['order_id'];
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result)
    
    ?>
    
    
    <?php
    $ot_shipping_amount=$row['class->ot_shipping'];
    $ot_total_amount=$row['class->ot_total'];
    //echo $ot_shipping_amount;
    
    
    if ($ot_shipping_amount>0) {
    
    echo "<a target='_blank' href='https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=some@mail.net&item_name=Online_Order&item_number=&amount=$ot_total_amount&no_shipping=2&no_note=1&currency_code=USD&bn=PP-BuyNowBF&charset=UTF-8'>Please click here to Pay.</a>";
    
    }else{
    
    echo "Your shipment total has not been updated.";
    }
    ?>
    Here is a link to view the table i am working with.
    http://onpointsys.com/table.jpg

    What i am tryint to achieve:
    I would like to SELECT a clause with two Where's. Example, one by order_id from the URL which i have already done and also by the class column which has a value of ot_shipping but must also query the data in the value column .

    Then i am trying to create an if statement where if the ot_shipping value is greater than zero display the link if not echo the text above.

    So at the end i am trying to get the following results.
    order_id=1 and ot_shipping=144.2700 so that i can then place ot_shipping in a variable.

    Any ideas?

  • #2
    New to the CF scene
    Join Date
    Aug 2006
    Location
    Germany, Heilbronn
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    PHP Code:
    $sql "SELECT * FROM zen_orders_total Where orders_id=".$_GET['order_id']." AND class=".$_GET['class']; 

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that is taking me in the right direction but the class is not in the url. I have to extract that from the database.

    What i need, by looking at the image, is the data in the value column sorted by the class (column) entry of ot_shipping based on the order_id from the URL. This would give me the value of 144.2700 so that i can then create a variable.

    Hope that makes sense. I work with PHP as needed.

    Ideas?

  • #4
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it to work. Wow. Thanks Fu86. With you advice i was able to change the code like this:
    PHP Code:
    <?php
    $sql 
    "SELECT * FROM zen_orders_total Where orders_id=".$_GET['order_id'] . AND class='ot_shipping'";
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result)

    ?>


    <?php
    $transfer_total=$row['value'];

    if ($transfer_total>0) {

    echo "
    <a target='_blank' href='https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=carrellcustom@sbcglobal.net&item_name=Online_Order&item_number=&amount=$transfer_total&no_shipping=2&no_note=1&currency_code=USD&bn=PP-BuyNowBF&charset=UTF-8'>Please click here to Pay.</a>";
    echo $transfer_total;

    }else{

    echo "
    Your shipment total has not been updated.";
    echo $transfer_total;
    }
    ?>
    After the code was in place i was able to get the correct entry in the database and display it on the screen to make sure it had the correct value.

    Thanks a million.
    Last edited by deemar; 08-30-2006 at 04:54 PM.


  •  

    Posting Permissions

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