JHedge JHedge - 2 months ago 5x
PHP Question

Hide 'no results found' until form clicked

I have a db query in WordPress that works Okay, but the echo no results found is visible on page load.

Is there a way of not showing the 'no results found' message until the form submit button is clicked?

Here is my code:

if(empty($results)) { echo "<p>no results found</p>"; } else { foreach($results as $r) { echo "<ul><li><p><a href=\"?$r->id\">$r->fb_name</a> - $r->tel</p></li></ul>";}}

Thanks for your help :)


Check that form is submitted or not

if(empty($results)  && isset($_POST['submit'])) 

here submit is the name of your submit button