Jump to content

PHP SELECT Where clause has multiple requests


deemar

Recommended Posts

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.";
}
?>[/CODE]
Here is a link to view the table i am working with.
[URL=http://onpointsys.com/table.jpg]http://onpointsys.com/table.jpg[/URL]

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?
Link to comment
Share on other sites

[code]
<?php
//$result = mysql_query("SELECT image_name from photo_album WHERE file_name=".$_GET['username'],$db);

//$result = "SELECT * FROM zen_orders_total Where orders_id='15' AND class='ot_shipping'
//UNION
//SELECT * FROM zen_orders_total Where orders_id='1' AND class='ot_total'";
$result = "select orders_id, (select value from zen_orders_total where orders_id=15 and class='ot_total') as total, (select value from zen_orders_total where orders_id=15 and class='ot_shipping') as shipping from zen_orders_total where orders_id";

//$result11 = mysql_query($result) or die (mysql_error());
$row = mysql_fetch_array($result)




?>


<?php

$shipping_total=$result['shipping'];
$transfer_total=$result['total'];


if ($shipping_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 $shipping_total;
echo $transfer_total;

}else{

echo 'Your shipment total has not been updated.';
echo $shipping_total;
echo $transfer_total;
}
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.