Skip to main content
Inspiring
August 14, 2017
Answered

Issues with "Message if no matching record is found"

  • August 14, 2017
  • 2 replies
  • 838 views

Hello Friends,

Good day all!

Please could someone review my code and tell me where I am wrong.

Using the dreamweaver code below ( although a number of fields has been removed due to length), I want the page to echo message if no matching record is found

mysql_select_db($database_XXXXX_DB, $XXXXX_DB);

$query_rsTaxPmts = sprintf("SELECT tpmt_id, code, phone

FROM tbl_tax

GROUP BY code", GetSQLValueString($colname_rsTaxPmts, "text"),GetSQLValueString($srcphone_rsTaxPmts, "text"));

$rsTaxPmts = mysql_query($query_rsTaxPmts, $XXXXX_DB) or die(mysql_error());

$row_rsTaxPmts = mysql_fetch_assoc($rsTaxPmts);

if (($row_rsTaxPmts)== 0) {

echo "<div align='center' class='alert alert-info' style='float:none; width:auto; height:auto; background-color:#CCC;'><span style='font-size:x-large;'><i class='fa fa-info-circle' aria-hidden='true'></i> No Records found!</span><br>Do a search using Payers TIN or Phone Number</div>";

}

$totalRows_rsTaxPmts = mysql_num_rows($rsTaxPmts);

The code actually works. It show: No Records found! Do a search using Payers TIN or Phone Number as expected. But it also shows the same message once the page if loaded before I even enter my search criteria. I don't want it to show when the page is loaded. I want the message to show after I press the search button and IFF there is no matching record.

Please kindly advice me where I am wrong. I appreciate in advance.

Thank you

Mike

This topic has been closed for replies.
Correct answer osgood_

https://forums.adobe.com/people/Prince+Mike  wrote

Hello Friends,

Good day all!

Please could someone review my code and tell me where I am wrong.

Using the dreamweaver code below ( although a number of fields has been removed due to length), I want the page to echo message if no matching record is found

mysql_select_db($database_XXXXX_DB, $XXXXX_DB);

$query_rsTaxPmts = sprintf("SELECT tpmt_id, code, phone

FROM tbl_tax

GROUP BY code", GetSQLValueString($colname_rsTaxPmts, "text"),GetSQLValueString($srcphone_rsTaxPmts, "text"));

$rsTaxPmts = mysql_query($query_rsTaxPmts, $XXXXX_DB) or die(mysql_error());

$row_rsTaxPmts = mysql_fetch_assoc($rsTaxPmts);

if (($row_rsTaxPmts)== 0) {

echo "<div align='center' class='alert alert-info' style='float:none; width:auto; height:auto; background-color:#CCC;'><span style='font-size:x-large;'><i class='fa fa-info-circle' aria-hidden='true'></i> No Records found!</span><br>Do a search using Payers TIN or Phone Number</div>";

}

$totalRows_rsTaxPmts = mysql_num_rows($rsTaxPmts);

The code actually works. It show: No Records found! Do a search using Payers TIN or Phone Number as expected. But it also shows the same message once the page if loaded before I even enter my search criteria. I don't want it to show when the page is loaded. I want the message to show after I press the search button and IFF there is no matching record.

Please kindly advice me where I am wrong. I appreciate in advance.

Thank you

Mike

That should work if you use the below variable and single ( ) :

if ($totalRows_rsTaxPmts == 0 ) {

}

You have assigned the number of rows returned for the query $rsTaxPmts to $totalRows_rsTaxPmts NOT $row_rsTaxPmts

$totalRows_rsTaxPmts = mysql_num_rows($rsTaxPmts);

2 replies

osgood_Correct answer
Legend
August 15, 2017

https://forums.adobe.com/people/Prince+Mike  wrote

Hello Friends,

Good day all!

Please could someone review my code and tell me where I am wrong.

Using the dreamweaver code below ( although a number of fields has been removed due to length), I want the page to echo message if no matching record is found

mysql_select_db($database_XXXXX_DB, $XXXXX_DB);

$query_rsTaxPmts = sprintf("SELECT tpmt_id, code, phone

FROM tbl_tax

GROUP BY code", GetSQLValueString($colname_rsTaxPmts, "text"),GetSQLValueString($srcphone_rsTaxPmts, "text"));

$rsTaxPmts = mysql_query($query_rsTaxPmts, $XXXXX_DB) or die(mysql_error());

$row_rsTaxPmts = mysql_fetch_assoc($rsTaxPmts);

if (($row_rsTaxPmts)== 0) {

echo "<div align='center' class='alert alert-info' style='float:none; width:auto; height:auto; background-color:#CCC;'><span style='font-size:x-large;'><i class='fa fa-info-circle' aria-hidden='true'></i> No Records found!</span><br>Do a search using Payers TIN or Phone Number</div>";

}

$totalRows_rsTaxPmts = mysql_num_rows($rsTaxPmts);

The code actually works. It show: No Records found! Do a search using Payers TIN or Phone Number as expected. But it also shows the same message once the page if loaded before I even enter my search criteria. I don't want it to show when the page is loaded. I want the message to show after I press the search button and IFF there is no matching record.

Please kindly advice me where I am wrong. I appreciate in advance.

Thank you

Mike

That should work if you use the below variable and single ( ) :

if ($totalRows_rsTaxPmts == 0 ) {

}

You have assigned the number of rows returned for the query $rsTaxPmts to $totalRows_rsTaxPmts NOT $row_rsTaxPmts

$totalRows_rsTaxPmts = mysql_num_rows($rsTaxPmts);

BenPleysier
Community Expert
Community Expert
August 14, 2017

You need to place an IF statement to stop the message from being shown when no search criteria has been made. Something like

if ($search-criteria) && (($row_rsTaxPmts) == 0) {

      echo ....

}

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Inspiring
August 14, 2017

Dear BenPleysier,

THank you for your quick response.

However, I don't know how to apply this phrase ($search-criteria).

The search form has two search boxes which includes "phonennumber" and "TaxID" and only one of them can be used for the search per time using an OR operator.

Now sir please how do I apply your ($search-criteria) to my case based on the two boxes??

Thank you