simple PHP question ...............................................?

Mike S

New member
From us people:
first : for comparison use == not =
second: your query will allways return records of people with the phone number, and it can return multiple values.
so, you have to use different way to figure out if the number is not there.
It is not clear if you want to show all records if there are multiple matches, but here is one way to show the first match

result = mysql_query("SELECT * FROM whiteboard WHERE client_home_phone = '".$client_home_phone_b."'");

if ($row = mysql_fetch_array( $result )) {
echo "<br><br>open ppw?";
}
else {
echo "<br><br>HI";
}
 
you ever have one of those problems that make you feel stupid?

like "i can diffuse a nuclear bomb, but i can't remember how to tie my damned shoes" kind of dumb?

well...

here's one for you...

$result = mysql_query("SELECT * FROM whiteboard WHERE client_home_phone = '".$client_home_phone_b."'");

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

if ($client_home_phone_b = $row["client_home_phone"])
{
echo "<br><br>open ppw?";
}

else
{
echo "<br><br>HI";
}

} //end while


basically there is a post to this script, it opens the db and checks the phone number against the one in the database.. if it exists then it says "open PPW..

what i want is, if there IS NO number in the database that matches that, for it to say "HI" or.. really it will be filled with all of the information needed to create a new client.. but.. if i get it to say "HI" i can put the rest in there.

client_home_phone_b comes from the initial post page.

help?? 10 points to the first successful answer
by the way, You people are probably going to tell me that i need to check this against ID's and such, and that checking a phone number against a phone number isn't the way to do it properly. don't bother..

it needs to be this way, so please help with the question at hand
 
From us people:
first : for comparison use == not =
second: your query will allways return records of people with the phone number, and it can return multiple values.
so, you have to use different way to figure out if the number is not there.
It is not clear if you want to show all records if there are multiple matches, but here is one way to show the first match

result = mysql_query("SELECT * FROM whiteboard WHERE client_home_phone = '".$client_home_phone_b."'");

if ($row = mysql_fetch_array( $result )) {
echo "<br><br>open ppw?";
}
else {
echo "<br><br>HI";
}
 
Back
Top