dont_be_hasty Posted April 17, 2009 Share Posted April 17, 2009 Hi, So im creating a webpage using html, php and mysql. I have a form consisting of text boxes in which the user can enter values. So the user enters a value into the text box, and using php and mysql, the database display info relating this value. Example table: Table1(id, name, address, email, age). So say the user enters there name, it will display their address, email and age. But say the name doesnt exist in the database table, how do i display an message to say that it doesnt exist. Ive got it so that it will display a message if the text box is not filled in, but not sure how to go about displaying a message if the value does not exist. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/154506-solved-check-value-exists-in-a-database/ Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 You can see if anything was returned with mysql_num_rows(). If it's greater than 0 then display the information, else display error message. Quote Link to comment https://forums.phpfreaks.com/topic/154506-solved-check-value-exists-in-a-database/#findComment-812404 Share on other sites More sharing options...
dont_be_hasty Posted April 19, 2009 Author Share Posted April 19, 2009 Thanks, Was able to use mysql_num_rows() to check if anything was being returned and if not it was displaying an error. Quote Link to comment https://forums.phpfreaks.com/topic/154506-solved-check-value-exists-in-a-database/#findComment-813759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.