PDA

View Full Version : if - help


mmaserati
04-04-2008, 07:08 PM
i have several row columns I need to compare to determine what gets shown to the user in a web page and I cant get it correct. this the start of my code:o


I really appreciate any help someone may give. :thumbsup:

my code is:


$query="SELECT prod1id,prod2id,prod3id,prod4id FROM t1m_users WHERE `id` ='" .$_SESSION['id']. "' AND `idspr` = '" .$_SESSION['sID']. "' LIMIT 1";

$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){

$s1 = $row['prod1id'];
$s2 = $row['prod2id'];
$s3 = $row['prod3id'];
$s3 = $row['prod4id'];




}


if ($s4 > '' )& ($s3 > '') & ($s2 > '') & ($s1 > '') {

echo "Congratulations ! You have all the prod" ;


}else{

echo you need prod ;
}

ptmuldoon
04-04-2008, 07:13 PM
Your using a greater than sign to compare to a blank field. That should be changed != (which means not equal).

Unless the fields in your table are numeric. Then you need something like > 0

Andrew Johnson
04-04-2008, 07:24 PM
ptmuldoon is partially right - fix what he says, but also remember this isn't ASP, all your IF statements must be enclosed in one LARGE parthensis, also the AND operator is two ampersands

Change

if ($s4 > '' )& ($s3 > '') & ($s2 > '') & ($s1 > '') {


To

if (($s4 > '' )&& ($s3 > '') && ($s2 > '') && ($s1 > '')) {

mmaserati
04-04-2008, 07:29 PM
:o opps