I am trying to see if a person's name is in a database when they submit their name through a form. I do mysql_query(select from $table where name = $name); How would I write an if statement that would tell the person entering the name if they are in the database?
Well, if they're in the database, then your query (don't forget to put quotes (') around $name) will return the matching row(s). So use mysql_num_rows($result) to see how many matches there were. If mysql_num_rows($result) > 0, you've got a winner.
$sql = "select name from table where name = '$name'"; $result = mysql_query($sql); if($result) print "name exists"; else print "name does not exist";
you could also fetch the result and test the name against the user given name but that would be repetitive.