PDA

View Full Version : PHP Help, please



Lucky13
April 1st, 2001, 14:15
I need a little help:
Can I do something like "WHILE field1=Hello, field2[does NOT]=Goodbye"
Thanks a lot.
~Lucky13

Koolguy
April 1st, 2001, 15:24
$var = (condition) ? (value1) : (value2) ;

note: taken from another posting

Lucky13
April 1st, 2001, 15:39
I don't know if I get that...could you give me an example...?

lucifer
April 1st, 2001, 15:46
try

if ($field1=="Hello"){
if (empty($field2)){$field2="Goodbye";}
}

it's easyer on the brain

the way above is more concise but confussing

Lucky13
April 1st, 2001, 15:50
OHH...I'm sorry, I wasn't specific enough. I mean for when I get results from a DB. For example:

$result = mysql_query("SELECT * FROM database WHILE name=Dan [but] lastname[does NOT]=Lucka",$db);

So it will find all of the records with the name of "Dan" but NOT the last name of "Lucka"

Thanks a lot, and sorry for the misunderstanding.

lucifer
April 1st, 2001, 16:59
$result = mysql_db_query($db, "SELECT * FROM $table WHERE name like '$what_you want' AND lastname not like '$what_you_dont_want';");

look in the MySQL manual for more info on SQL - though i'm sure you can find a better SQL reference

Woofcat
April 1st, 2001, 17:26
@mysql_select_db('database');
$result=@mysql_query('select * from table where name="Dan" and lastname!="Lucka"');

Lucky13
April 1st, 2001, 17:26
sweet. It worked. Thanks a TON.

~Lucky13

Lucky13
May 26th, 2001, 08:32
hello...is there a way to do a query "WHERE name!=[empty]"?

Thanks

~Lucky13

lucifer
May 27th, 2001, 11:58
WHERE name!="" - 2 double quotes

Lucky13
May 27th, 2001, 16:37
Yeah...I got that...thanks anyway, though =)