Page 1 of 1

If statement with two conditions

Posted: Thu Mar 11, 2004 2:28 am
by Vestax
Hi All,

I'm a php newbie, and I'm having trouble creating this if statement with two conditions in it. Here's what I'm trying to get (some of my code is in dutch, but that's only my email body): I want two conditions in my bold if statement. I've pasted my code at the bottom of this email.
I've tried this, which I think should work:

Code: Select all

if ($orders_status_array[$status] == "In behandeling") && ($payment_method == "COD") {
the problem is in the $payment_method. I'm trying to define it by using a mysql query, but I'm having trouble assigning the query's value to $payment_method.

So my code should be something like this:

Code: Select all

$result = mysql_query("SELECT `payment_method` FROM `orders` WHERE `orders_id` = '$oid'")
   or die(mysql_error());
   $row = mysql_fetch_array($result);
   $payment_method = $row['payment_method']);
But this doesn't work, can anybody please tell me how to get this single result that comes out of my database (it's always one value) to $payment_method?

Thanks alot!

Vestax

Code: Select all

if (tep_not_null($action)) {
    switch ($action) {
      case 'update_order':
        $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
        $status = tep_db_prepare_input($HTTP_POST_VARS['status']);
        $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
        $order_updated = false;
        $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
        $check_status = tep_db_fetch_array($check_status_query);

        $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
        $check_status = tep_db_fetch_array($check_status_query);

        if ( ($check_status['orders_status'] != $status) || tep_not_null($comments)) {
          tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$oID . "'");

          $customer_notified = '0';
          if (isset($HTTP_POST_VARS['notify']) && ($HTTP_POST_VARS['notify'] == 'on')) {
            $notify_comments = '';
            if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) {
              $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
            }



		[b] if ($orders_status_array[$status] == "In behandeling") [/b]

{


$email = "Geachte Heer/Mevrouw, " . $payment_method . "\n\n\n" . "Uw bestelling bij " . STORE_NAME . " is in behandeling genomen, als u ervoor heeft gekozen om het bedrag vooraf over te maken, dan kunt u onderaan deze email de betalingsgegevens vinden." . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . "Betalingsgegevens:" . "\n\n" . "Soul2Soul Kidz" . "\n" . "Girorekening: 6945424 \n" . "Plaats: Eindhoven" . "\n" . "Omschrijving: Bestelnummer " . $oID . $payment_method .  "\n\n" . "Zodra uw betaling binnen is zullen de kleren verstuurd worden." . "\n\n" . "Met Vriendelijke Groet," . "\n\n\n" . "Soul2Soul Kidz";


}

else {
 
            $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);

}
EDITED BY BECH100: PLEASE USE BBCODE TO HIGHLIGHT YOUR CODE

Posted: Thu Mar 11, 2004 3:17 am
by Wayne
$payment_method = $row['payment_method']);
why the ) at the end of this ???
and the if statement

Code: Select all

if ( ( orders_status_arrayї$status] == "In behandeling") && ($payment_method == "COD") ){

Posted: Thu Mar 11, 2004 3:22 am
by Vestax
Thanks for the highlighting, as you can see I'm a newbie.

I've managed to define my $payment_method using the extract() function. My my only problem is the 'double' if statement.
This is what I'm trying to do:

Code: Select all

$payment_query = tep_db_query("select payment_method from orders where orders_id = '" . $oID . "'");
   extract(mysql_fetch_assoc($payment_query)); 
    


		if ($orders_status_array[$status] == "In behandeling") && ($payment_method == "Vooruitbetalen d.m.v. een overschrijving")

{
As you can see I've modified the mysql code a bit, according to other lines of code in the script. $payment_method now has the value "Vooruitbetalen d.m.v. een overschrijving", I only need to check it.
Something isn't right here, I'm not even sure if it's possible, but I think so.

Any help would be greatly appreciated.

Vestax

Posted: Thu Mar 11, 2004 3:31 am
by Vestax
Hi Wayne,

thanks for the quick reply, the ) was indeed a mistake, but I've solved the query in another way. Thanks alot for the if statement, I just didn't know I needed the double ().

Thanks alot! It's working now.