marquis Posted January 3, 2007 Share Posted January 3, 2007 after running a search through a database how do you get it to say no matches if nothing matched there search criteriaif you would like to see my code just ask Link to comment Share on other sites More sharing options...
CStrauss Posted January 3, 2007 Share Posted January 3, 2007 Well the most common way I see it is a if statement Like this: // Database connection here// Query database$sql = mysql_query("SELECT * FROM some_table WHERE data=$data");if(!$sql){ echo "No Matches Found";} Not sure if that is what your looking for or if your actually pulling data out first then doing a check but if that is the case then you just do an if statment comparing your results to what your searching for and pretty much do the same thing as above code.Hope that helps Link to comment Share on other sites More sharing options...
justsomeguy Posted January 3, 2007 Share Posted January 3, 2007 That wouldn't necessarily work, you would want to use this:if(mysql_num_rows($sql) == 0){ Link to comment Share on other sites More sharing options...
marquis Posted January 3, 2007 Author Share Posted January 3, 2007 yes this is the frist time for me to try do this and and that what i though to do first but it doesnt work$result = mysql_query($SQL); if(!$result)ECHO "NO MATCHES FOUND";after using justsomeguy's suggestion it worked fine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now