close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Search not filtering after I add additional "Where" clause in the recordset

Thread began 1/04/2015 11:10 pm by Blikbrein | Last modified 1/07/2015 1:36 pm by Blikbrein | 607 views | 6 replies

Jason ByrnesWebAssist

The recordset code is duplicated.

change lines 135 - 164:

<?php
$maxRows_WADAPayments = 1000;
$pageNum_WADAPayments = 0;
if (isset($_GET['pageNum_WADAPayments'])) {
$pageNum_WADAPayments = $_GET['pageNum_WADAPayments'];
}
$startRow_WADAPayments = $pageNum_WADAPayments * $maxRows_WADAPayments;

mysql_select_db($database_anna, $anna);
$query_WADAPayments = "SELECT PaymentsID, `Users`.`UserFirstName` AS Users_UserFirstName, Users.UserSurname, `ContractTracking`.`PackageID` AS ContractTracking_PackageID, PaymentDate, PaymentDocno, PaymentDebit, PaymentCredit FROM Payments LEFT JOIN Users ON Users.UserID = Payments.PaymentClientID LEFT JOIN ContractTracking ON ContractTracking.ContractID = Payments.PaymentContractTrackingID WHERE PaymentDebit > 0 OR PaymentCredit > 0 ORDER BY Users.UserSurname ASC, `Users`.`UserFirstName` ASC, PaymentDate ASC";
setQueryBuilderSource($query_WADAPayments,$WADbSearch1,false);
$query_limit_WADAPayments = sprintf("%s LIMIT %d, %d", $query_WADAPayments, $startRow_WADAPayments, $maxRows_WADAPayments);
$WADAPayments = mysql_query($query_limit_WADAPayments, $anna) or die(mysql_error());
$row_WADAPayments = mysql_fetch_assoc($WADAPayments);

if (isset($_GET['totalRows_WADAPayments'])) {
$totalRows_WADAPayments = $_GET['totalRows_WADAPayments'];
} else {
$all_WADAPayments = mysql_query($query_WADAPayments, $anna);
$totalRows_WADAPayments = mysql_num_rows($all_WADAPayments);
}
$totalPages_WADAPayments = ceil($totalRows_WADAPayments/$maxRows_WADAPayments)-1;

mysql_select_db($database_anna, $anna);
$query_WADATotals = "SELECT SUM(PaymentDebit) AS Debits, SUM(PaymentCredit) AS Credits, SUM(PaymentDebit) - SUM(PaymentCredit) as Balance FROM Payments LEFT JOIN Users ON Users.UserID = Payments.PaymentClientID LEFT JOIN ContractTracking ON ContractTracking.ContractID = Payments.PaymentContractTrackingID";
setQueryBuilderSource($query_WADATotals,$WADbSearch2,false);
$WADATotals = mysql_query($query_WADATotals, $anna) or die(mysql_error());
$row_WADATotals = mysql_fetch_assoc($WADATotals);
$totalRows_WADATotals = mysql_num_rows($WADATotals);
?>



to:

<?php
$maxRows_WADAPayments = 1000;
$pageNum_WADAPayments = 0;
if (isset($_GET['pageNum_WADAPayments'])) {
$pageNum_WADAPayments = $_GET['pageNum_WADAPayments'];
}
$startRow_WADAPayments = $pageNum_WADAPayments * $maxRows_WADAPayments;

mysql_select_db($database_anna, $anna);
$query_WADAPayments = "SELECT PaymentsID, `Users`.`UserFirstName` AS Users_UserFirstName, Users.UserSurname, `ContractTracking`.`PackageID` AS ContractTracking_PackageID, PaymentDate, PaymentDocno, PaymentDebit, PaymentCredit FROM Payments LEFT JOIN Users ON Users.UserID = Payments.PaymentClientID LEFT JOIN ContractTracking ON ContractTracking.ContractID = Payments.PaymentContractTrackingID WHERE PaymentDebit > 0 OR PaymentCredit > 0 ORDER BY Users.UserSurname ASC, `Users`.`UserFirstName` ASC, PaymentDate ASC";
setQueryBuilderSource($query_WADAPayments,$WADbSearch1,false);
$query_limit_WADAPayments = sprintf("%s LIMIT %d, %d", $query_WADAPayments, $startRow_WADAPayments, $maxRows_WADAPayments);
$WADAPayments = mysql_query($query_limit_WADAPayments, $anna) or die(mysql_error());
$row_WADAPayments = mysql_fetch_assoc($WADAPayments);

if (isset($_GET['totalRows_WADAPayments'])) {
$totalRows_WADAPayments = $_GET['totalRows_WADAPayments'];
} else {
$all_WADAPayments = mysql_query($query_WADAPayments, $anna);
$totalRows_WADAPayments = mysql_num_rows($all_WADAPayments);
}
$totalPages_WADAPayments = ceil($totalRows_WADAPayments/$maxRows_WADAPayments)-1;
?>




NOTE: the recordset criteria you mention is contrary to what you originally wrote, that is the basis for the confusion.

  and that items with a 0 in PaymentDebit AND 0 in PaymentCredit should not be shown  



that is why I suggested using AND.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...