Re: finding data

From: Date: Thu, 15 Apr 2004 15:54:03 +0000
Subject: Re: finding data
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-33908@lists.php.net to get a copy of this message
the way I would do this is with count() $row = mysql_fetch_assoc("SELECT count(*) as c FROM bivalues WHERE myvalue = '$zchar'") if ($row['c'] > 0) { echo 'result 2 - found it' }else{ echo 'NOT found' } hope it helps Pete Douglas D Hull wrote:
I am trying to find data, or if not found set a variable to "Err". myvalue being a variable in my database and $zchar being my value to find. The following result is never 1 even if no values were found, so the result is always 2. If the finding value does exist in my database this does find the correct value: if (!$result = mysql_query("SELECT * FROM bivalues WHERE myvalue = '$zchar'")) { echo 'result 1 - not found'; $myresut = "Err"; } else { {echo 'result 2 - found it' } The following result is never 2 even if the value actually exist in my database, so the result is always 1: if (!$result = mysql_query("SELECT * FROM bivalues WHERE myvalue = $zchar")) { echo 'result 1 - not found'; $myresult = "Err"; } else { {echo 'result 2 - found it' } Thanks for any help, Doug


« previous php.db (#33908) next »