Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Empty search results message shows up on page load

Participant ,
Sep 23, 2008 Sep 23, 2008
******************
if ($totalRows_rs_searchresults == 0)
{ // Show if recordset empty ?>
<div align="center" class="body">Sorry your search returned no results, please try again</div>
******************

That works fine but obviously it shows up when the page is first loaded as the number of search results is zero. So how do I get that message to NOT show up until the form has been submitted for the first time?

Cheers

Dave


TOPICS
Server side applications
582
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 24, 2008 Sep 24, 2008
davecheet wrote:
> ******************
> if ($totalRows_rs_searchresults == 0)
> { // Show if recordset empty ?>
> <div align="center" class="body">Sorry your search returned no results, please
> try again</div>
> ******************
>
> That works fine but obviously it shows up when the page is first loaded as the
> number of search results is zero. So how do I get that message to NOT show up
> until the form has been submitted for the first time?

If you're using the GET method to submit th...
Translate
LEGEND ,
Sep 24, 2008 Sep 24, 2008
davecheet wrote:
> ******************
> if ($totalRows_rs_searchresults == 0)
> { // Show if recordset empty ?>
> <div align="center" class="body">Sorry your search returned no results, please
> try again</div>
> ******************
>
> That works fine but obviously it shows up when the page is first loaded as the
> number of search results is zero. So how do I get that message to NOT show up
> until the form has been submitted for the first time?

If you're using the GET method to submit the search form, amend the
conditional statement like this:

if (isset($_GET['search'])) && $totalRows_rs_searchresults == 0)

Change the value of 'search' to the name of the field being used to
filter the results. If you're using the POST method, use $_POST instead
of $_GET.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 24, 2008 Sep 24, 2008
LATEST
That worked perfectly thanks David. I had to delete one of your brackets though.
if (isset($_POST['search'])) && $totalRows_rs_searchresults == 0)
became
if (isset($_POST['search']) && $totalRows_rs_searchresults == 0)

Thanks again for your help.

Cheers

Dave
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines