View Full Version : mysql question

June 10th, 2010, 11:12 AM
I have a table with two columns. First is an id and the other is a user. How can I test from a php page that a line (id + user) exists in the table?

June 10th, 2010, 11:28 AM
There's a lot of ways to do that, here's one:

$request = mysql_query("SELECT * FROM table WHERE id = 'foo' AND user = 'bar'");
if(!mysql_num_rows($request)) {
print 'No results found!';
} else {
// Do your stuff

June 10th, 2010, 04:10 PM
Thanks, it's working beautifully.