close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

nested

Thread began 6/21/2017 9:56 am by Leon | Last modified 6/27/2017 11:47 am by Ray Borduin | 3559 views | 14 replies |

Leon

nested

I have a question. I am trying to build a nested region within a repeat region. the outer region holds the states we have had projects in. The inner region listes the projects that we have completed in those states. I am able to created the outer region, but the inner region does not populate on the page. I have include a copy of the bare code for you to take a look and help me understand how to correct this. Thank you.

<?php require_once('Connections/mitoWebsiteMSQLI.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php
$Recordset1 = new WA_MySQLi_RS("Recordset1",$mitoWebsiteMSQLI,50);
$Recordset1->setQuery("SELECT DISTINCT completedProjects.state FROM completedProjects ORDER BY completedProjects.state ASC");
$Recordset1->execute();
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
while(!$Recordset1->atEnd()) {
?>
<h2><?php echo($Recordset1->getColumnVal("state")); ?></h2>
<?php
$Recordset1->moveNext();
}
$Recordset1->moveFirst(); //return RS to first record
?>

<?php
while(!$Recordset1->atEnd()) {
?>

Sign in to reply to this post

Ray BorduinWebAssist

Add the second repeat region below and then manually move it inside. Dreamweaver won't let you nest repeat regions directly, but they will work if you move the code manually.

Sign in to reply to this post
Did this help? Tips are appreciated...

Leon

Thanks Ray that has worked for the repeat region.

<?php require_once('Connections/mitoWebsiteMSQLI.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php
$Recordset1 = new WA_MySQLi_RS("Recordset1",$mitoWebsiteMSQLI,0);
$Recordset1->setQuery("SELECT DISTINCT completedProjects.state FROM completedProjects ORDER BY completedProjects.state ASC");
$Recordset1->execute();
?>
<?php
$Recordset2 = new WA_MySQLi_RS("Recordset2",$mitoWebsiteMSQLI,10);
$Recordset2->setQuery("SELECT * FROM completedProjects ORDER BY project_name ASC");
$Recordset2->execute();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
while(!$Recordset1->atEnd()) {
?>
<h2><?php echo($Recordset1->getColumnVal("state")); ?></h2>
<?php
while(!$Recordset2->atEnd()) {
?>
<?php echo($Recordset2->getColumnVal("project_name")); ?><br>
<?php
$Recordset2->moveNext();
}
$Recordset2->moveFirst(); //return RS to first record
?>

<?php
$Recordset1->moveNext();
}
$Recordset1->moveFirst(); //return RS to first record
?>




I am also trying to print the projects that are listed under the state. when I go into the record set and try to set the filter to state the inner project repeat region disappears? Any advice mate?

Sign in to reply to this post

Ray BorduinWebAssist

I haven't seen that happen. I can do some testing to reproduce, but probably you will just have to re-add it after editing the recordset since it is removed. Maybe copy the code first and then paste it back after updating the recordset to save some time.

Sign in to reply to this post
Did this help? Tips are appreciated...

Leon

Sorry, its probably me, but I do not understand what you have just said. If I changed the recordset and drop the filter the subset will apear on the page and adding it causes the inner to disapear. Is this being caused by adding the filter from the first recordset 'state' and linking it to the URL Peram 'state' and how can I fix this?

Sign in to reply to this post

Ray BorduinWebAssist

I think I understand this time.... You will need to copy and paste the Recordset2 recordset code from the top of the page and put it below the while statement for Recordset1. That way it will be recreated for each row of Recordset1 and can show the correct associated results for the first repeated region.

Sign in to reply to this post
Did this help? Tips are appreciated...

Leon

I was able to move the data from the header to Recordset1 while statement:

<?php
while(!$Recordset1->atEnd()) {
?>

<h2><?php echo($Recordset1->getColumnVal("state")); ?></h2>

<?php
$Recordset2 = new WA_MySQLi_RS("Recordset2",$mitoWebsiteMSQLI,10);
$Recordset2->setQuery("SELECT * FROM completedProjects ORDER BY project_name ASC");
$Recordset2->execute();
?>
<?php


while(!$Recordset2->atEnd()) {

echo($Recordset2->getColumnVal("project_name")); ?><br>
<?php
$Recordset2->moveNext();
}
$Recordset2->moveFirst(); //return RS to first record
//end of projects inner loop?>

<?php
$Recordset1->moveNext();
}
$Recordset1->moveFirst(); //return RS to first record
?>


it has created the repeated date for recordset2. But I continue to have the same issue. It will repeat the project data, but not linked to each state. How can I join the data from recordset1 to recordset 2?

Sign in to reply to this post

Ray BorduinWebAssist

You still have to add a parameter to filter Recordset2 with the state value from Recordset1. It will look something like:

php:
<?php

$Recordset2 
= new WA_MySQLi_RS("Recordset2",$mitoWebsiteMSQLI,10);
$Recordset2->setQuery("SELECT * FROM completedProjects WHERE project_state = ? ORDER BY project_name ASC");
$Recordset2->bindParam("s","".$Recordset1->getColumnVal("state")  ."","-1");
$Recordset2->execute();
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Leon

Thank you. When I add the where state and param, with the app or the hand coding above, I receive the same result. Projects repeat region disapears from the page?

Sign in to reply to this post

Ray BorduinWebAssist

It must not be returning any results. Are you sure the state column references are correct?

I'd probably add this to debug after the execute() line:

php:
var_dump($Recordset2);



That might help you determine why there are no results returned and what is wrong with your SQL.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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