Skip to main content
July 22, 2007
Answered

SEARCH AND RESULT IN THE SAME PAGE

  • July 22, 2007
  • 3 replies
  • 666 views
Hi,

Using: mySQL, PHP, DW

As I have the results appearing on the same page as search function, the show if recordset is empty will not properly work, since the "No Records Match Your Criteria" message will appear as soon as you open the page.

how do I get this message to only show after the user have searched?

Hope someone can point me out a solution for this,
MEM
This topic has been closed for replies.
Correct answer Newsgroup_User
oicram wrote:
> As I have the results appearing on the same page as search function, the show
> if recordset is empty will not properly work, since the "No Records Match Your
> Criteria" message will appear as soon as you open the page.

This is a failing of the way the Show if recordset is empty server
behavior, but it's easy to remedy.

> how do I get this message to only show after the user have searched?

The code as inserted by Dreamweaver looks like this (recordsetName will
be replaced by whatever name you gave your recordset):

<?php if ($totalRows_recordsetName == 0) { // Show if recordset empty ?>

Change it like this:

<?php if (array_key_exists('submitButtonName', $_POST) &&
$totalRows_recordsetName == 0) { // Show if recordset empty ?>

Replace submitButtonName with the name of the submit button in your
search form. That's all there is to it.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

3 replies

Inspiring
July 23, 2007
oicram wrote:
> I have change the $_POST to $_GET since my form is getting, and it works
> perfectly.

Glad to have been of help.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
July 23, 2007

<?php if (array_key_exists('submitButtonName', $_POST) &&
$totalRows_recordsetName == 0) { // Show if recordset empty ?>

Thanks a lot. Its precious to know php at least make a if with a nice array_key_exists. :)

I have change the $_POST to $_GET since my form is getting, and it works perfectly.

Thanks a lot.
Newsgroup_UserCorrect answer
Inspiring
July 22, 2007
oicram wrote:
> As I have the results appearing on the same page as search function, the show
> if recordset is empty will not properly work, since the "No Records Match Your
> Criteria" message will appear as soon as you open the page.

This is a failing of the way the Show if recordset is empty server
behavior, but it's easy to remedy.

> how do I get this message to only show after the user have searched?

The code as inserted by Dreamweaver looks like this (recordsetName will
be replaced by whatever name you gave your recordset):

<?php if ($totalRows_recordsetName == 0) { // Show if recordset empty ?>

Change it like this:

<?php if (array_key_exists('submitButtonName', $_POST) &&
$totalRows_recordsetName == 0) { // Show if recordset empty ?>

Replace submitButtonName with the name of the submit button in your
search form. That's all there is to it.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/