RE: [PHP] if statement help

2005-11-04 Thread Ford, Mike
On 03 November 2005 15:26, Brent Baisley wrote:

 You only need one if. The parenthesis will evaluation order.
 
 if( ( !empty( $var1 )  || ( !empty( $var2 )  !empty( $var3 ) ) ||
 $var1 == something  ) 

However, the $var1==something test is redundant in this, since if that is 
true the !empty($var1) test will also be true and the rest of the test will not 
be evaluated.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] if statement help

2005-11-03 Thread Jason Gerfen
I am trying to determine if it is worth my time to attempt a if 
statement similar to the following.  I am asking because I have not 
found any references to something like this:


if( ( !empty( $var1 ) ) || ( if( !empty( $var2 ) )  ( !empty( $var3 ) 
) ) || ( $var1 == something ) ) {

// do something fancy
}

--
Jason Gerfen

My girlfriend threated to
leave me if I went boarding...
I will miss her.
~ DIATRIBE aka FBITKK

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] if statement help

2005-11-03 Thread Brent Baisley

You only need one if. The parenthesis will evaluation order.

if( ( !empty( $var1 )  || ( !empty( $var2 )  !empty( $var3 ) ) ||  
$var1 == something  )


On Nov 3, 2005, at 10:13 AM, Jason Gerfen wrote:

I am trying to determine if it is worth my time to attempt a if  
statement similar to the following.  I am asking because I have not  
found any references to something like this:


if( ( !empty( $var1 ) ) || ( if( !empty( $var2 ) )  ( !empty 
( $var3 ) ) ) || ( $var1 == something ) ) {

// do something fancy
}

--
Jason Gerfen

My girlfriend threated to
leave me if I went boarding...
I will miss her.
~ DIATRIBE aka FBITKK

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] sql statement help needed

2004-06-30 Thread Chris W. Parker
hello,

i've had to change some of my tables to accomodate some greater
flexibility in the application that uses it and because of this i need
to go through and update all the records. i've done one table by hand
and it had about 100 records and took about 20 minutes. but this next
table has about 550 records and i really don't feel like doing this all
by hand. i'm using MySQL Control Center to do this editing so i'd like
to know if there's a single SQL statement i could use to update all the
rows.

here is a simple representation:

products: (pay no attention to the poor choice in column names. this is
a retrofitting and will be fixed in later versions.)
+--+---+
| id   | sequential_id |
+--+---+
| PRDX-41  | 1 |
| ABCX-01  | 2 |
| FF00-11  | 3 |
\/\/\/\/\/\/\/\/
| ETC0-99  |   500 |
+--+---+

the 'prod_sequential_id' column was added later to the
products_categories table.

products_categories:
+-+-+++
| id  | prod_id | prod_sequential_id | cat_id |
+-+-+++
|   1 | PRDX-41 |  0 | 41 |
|   2 | PRDX-41 |  0 | 15 |
|   3 | ABCX-01 |  0 | 13 |
|   4 | FF00-11 |  0 | 89 |
\/\/\/\/\/\/\/\/
| 610 | ETC0-99 |  0 | 41 |
+-+-+++

so... as you can see, prod_sequential_id has all 0's in its column. it
should contain the value of products.sequential_id WHERE
products_categories.prod_id = products.id.

the problem is that i'm not sure how to do this all in one statement (or
if it's even possible):

(i know the following does not work, but it's basically the logic i
think i need.)

UPDATE products_categories AS pc, products AS p
SET pc.prod_sequential_id = p.id
WHERE pc.prod_id = p.id;


thanks for your help.
chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] sql statement help needed

2004-06-30 Thread Binay

- Original Message - 
From: Chris W. Parker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 01, 2004 3:33 AM
Subject: [PHP] sql statement help needed


 hello,
 
 i've had to change some of my tables to accomodate some greater
 flexibility in the application that uses it and because of this i need
 to go through and update all the records. i've done one table by hand
 and it had about 100 records and took about 20 minutes. but this next
 table has about 550 records and i really don't feel like doing this all
 by hand. i'm using MySQL Control Center to do this editing so i'd like
 to know if there's a single SQL statement i could use to update all the
 rows.
 
 here is a simple representation:
 
 products: (pay no attention to the poor choice in column names. this is
 a retrofitting and will be fixed in later versions.)
 +--+---+
 | id   | sequential_id |
 +--+---+
 | PRDX-41  | 1 |
 | ABCX-01  | 2 |
 | FF00-11  | 3 |
 \/\/\/\/\/\/\/\/
 | ETC0-99  |   500 |
 +--+---+
 
 the 'prod_sequential_id' column was added later to the
 products_categories table.
 
 products_categories:
 +-+-+++
 | id  | prod_id | prod_sequential_id | cat_id |
 +-+-+++
 |   1 | PRDX-41 |  0 | 41 |
 |   2 | PRDX-41 |  0 | 15 |
 |   3 | ABCX-01 |  0 | 13 |
 |   4 | FF00-11 |  0 | 89 |
 \/\/\/\/\/\/\/\/
 | 610 | ETC0-99 |  0 | 41 |
 +-+-+++
 
 so... as you can see, prod_sequential_id has all 0's in its column. it
 should contain the value of products.sequential_id WHERE
 products_categories.prod_id = products.id.
 
 the problem is that i'm not sure how to do this all in one statement (or
 if it's even possible):
 
 (i know the following does not work, but it's basically the logic i
 think i need.)
 
 UPDATE products_categories AS pc, products AS p
 SET pc.prod_sequential_id = p.id
 WHERE pc.prod_id = p.id;

why can't you do like this.
UPDATE products_categories set prod_sequential_id = prod_id 

in one go.

Thanks
Binay



 
 
 thanks for your help.
 chris.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php