close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Unexpected results with a nested recordset

Thread began 12/02/2022 6:17 am by MWilson | Last modified 12/05/2022 10:50 am by MWilson | 20 views | 5 replies

MWilson

Unexpected results with a nested recordset

Hi Ray, I have a page which lists all tests that are available to the logged in user, and which displays a badge next to each test showing if it has already been completed and on which date. This is done using a nested recordset and a Show If Recordset Not Empty command as follows:

<?php
$rsTests = new WA_MySQLi_RS("rsTests",$Composite,0);
$rsTests->setQuery("SELECT * FROM CPD_test WHERE CPD_test.Secondary = 0 AND FCANo IS NULL AND Live = 1 ORDER BY CPD_test.Title");
$rsTests->execute();
?>

<?php
$wa_startindex = 0;
while(!$rsTests->atEnd()) {
$wa_startindex = $rsTests->Index;
?>

<?php
$WADACPD = new WA_MySQLi_RS("WADACPD",$Composite,0);
$WADACPD->setQuery("SELECT CPD.CPD_ID, CPD.User_ID, CPD.Course_name, CPD.`Date` FROM CPD WHERE Score > 0 AND CPD.User_ID = ? AND CPD.Course_name REGEXP ? ORDER BY CPD.`Date` DESC");
$WADACPD->bindParam("i", "".$_SESSION['CPD_ID'] ."", "-1"); //colname
$WADACPD->bindParam("s", "".(preg_quote($rsTests->getColumnVal("Title",false))) ."", "-1"); //paramTest
$WADACPD->execute();?>

<?php if ($WADACPD->TotalRows > 0) { // Show if mysqli recordset not empty ?>
Completed <?php echo date("d.n.y",strtotime($WADACPD->getColumnVal('Date')));?>
<?php } // Show if mysqli recordset not empty ?>

<?php
$rsTests->moveNext();
}
$rsTests->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>



I've discovered an anomaly though - there are two tests, one called "Certification" and the other "Senior Manager & Certification Regime (SM&CR)" and the above code is showing both of these as having been completed, even though the one called "Certification" hasn't been completed. I've tried various alterations to the above query but can't get it to work as it should. Can you help?

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...