Solved

Nested Repeat Region - Dreamweaver CS4 - PHP - MySQL

Posted on 2009-05-12
7
1,392 Views
Last Modified: 2012-05-06
Hi Experts

Would really appreciate some help with creating a nested repeat region. I am using Dreamweaver CS4 and the developer toolobox is no longer available. (wouldn't want to use it anyway!)

I am using the code below to group lists of students under dates. It is returning the correct result for the first loop but not for subsequent ones.

Would have been surprised it if was as easy as I've tried but may well use this in other areas of my current project so would really appreciate your expertise.

Many thanks
// Recordset to return list of dates
$grading_date_rsDateGroup = "2009-02-01";
if (isset($_GET['date'])) {
  $grading_date_rsDateGroup = $_GET['date'];
}
$print_stamp_rsDateGroup = "1";
if (isset($_GET['stamp'])) {
  $print_stamp_rsDateGroup = $_GET['stamp'];
}
mysql_select_db($database_connEACKDK, $connEACKDK);
$query_rsDateGroup = sprintf("SELECT g.date, g.id FROM gradings AS g        JOIN students s ON g.id = s.id JOIN print_queue p on g.id = p.student_id AND p.timestamp = %s WHERE g.timestamp = %s GROUP BY g.date ORDER BY g.date ASC", GetSQLValueString($print_stamp_rsDateGroup, "int"),GetSQLValueString($grading_date_rsDateGroup, "date"));
$rsDateGroup = mysql_query($query_rsDateGroup, $connEACKDK) or die(mysql_error());
$row_rsDateGroup = mysql_fetch_assoc($rsDateGroup);
$totalRows_rsDateGroup = mysql_num_rows($rsDateGroup);
 
// Recordset for nested repeat
$grading_date_rsGradersTest = "2009-02";
if (isset($_GET['date'])) {
  $grading_date_rsGradersTest = $_GET['date'];
}
$date_group_rsGradersTest = "2009-05-01";
if (isset($row_rsDateGroup['date'])) {
  $date_group_rsGradersTest = $row_rsDateGroup['date'];
}
$print_stamp_rsGradersTest = "1";
if (isset($_GET['stamp'])) {
  $print_stamp_rsGradersTest = $_GET['stamp'];
}
mysql_select_db($database_connEACKDK, $connEACKDK);
$query_rsGradersTest = sprintf("SELECT g.id,  g.date,  g.timestamp,  s.firstName,  s.lastname,  s.belt_size,  b1.belt AS current,   b2.belt AS new, DATE_FORMAT(g.date, '%%M %%Y') as fdate FROM gradings AS g        JOIN students s ON g.id = s.id  JOIN print_queue p on g.id = p.student_id AND p.timestamp = %s      LEFT OUTER JOIN belts b1 ON g.current = b1.id  LEFT OUTER JOIN belts b2 ON g.new = b2.id WHERE g.timestamp = %s AND g.date = %s ORDER BY g.date ASC, b1.id DESC, s.lastname ASC", GetSQLValueString($print_stamp_rsGradersTest, "int"),GetSQLValueString($grading_date_rsGradersTest, "date"),GetSQLValueString($date_group_rsGradersTest, "date"));
$rsGradersTest = mysql_query($query_rsGradersTest, $connEACKDK) or die(mysql_error());
$row_rsGradersTest = mysql_fetch_assoc($rsGradersTest);
$totalRows_rsGradersTest = mysql_num_rows($rsGradersTest);
 
// Nested repeat in HTML
<table width="97%" border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td width="70%" valign="top"><table width="100%" border="1" cellspacing="0" cellpadding="5">
      <?php do { ?>
        <tr>
          <td><?php echo $row_rsDateGroup['date']; ?><br />
          <?php do { ?>
            <?php echo $row_rsGradersTest['firstName']; ?> <?php echo $row_rsGradersTest['lastname']; ?><br />
            <?php } while ($row_rsGradersTest = mysql_fetch_assoc($rsGradersTest)); ?>
            </td>
        </tr>
        <?php } while ($row_rsDateGroup = mysql_fetch_assoc($rsDateGroup)); ?>
    </table>
     </td>
    </tr>
</table>

Open in new window

0
Comment
Question by:sirnutty1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:Jonah11
ID: 24369413
Its not clear exactly how you want it displayed, but one thing i notice is that you open a <tr>  on line 37, then a <td> on 38 (everything ok so far), but now you open a new <tr> on 40 before the open <td> is closed.  are you trying to nest a table within a table?  if you could describe how you wanted the output to look exactly, i could better help.
0
 
LVL 5

Expert Comment

by:dhobale
ID: 24369994
Write your code in following format:

$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
    echo "<td>$row_rsDateGroup['date'];  <br>" .
         "next field...".

YOU should PUT YOUR 2nd loop here
}

0
 

Author Comment

by:sirnutty1
ID: 24374866
I'm getting myself a little confused!!

If I have the simplified code as below with just one DW repeat region, could you possibly give me an idea on how I would enter a nested repeat region that uses the date row from the parent repeat region as a variable?

Sincere thanks
//PHP
mysql_select_db($database_connEACKDK, $connEACKDK);
$query_rsDateGroup = "SELECT g.date, g.id FROM gradings AS g GROUP BY g.date ORDER BY g.date ASC";
$rsDateGroup = mysql_query($query_rsDateGroup, $connEACKDK) or die(mysql_error());
$row_rsDateGroup = mysql_fetch_assoc($rsDateGroup);
$totalRows_rsDateGroup = mysql_num_rows($rsDateGroup);
 
//HTML
<table width="97%" border="1" cellspacing="0" cellpadding="5">
      <?php do { ?>
  <tr>
    <td valign="top"><?php echo $row_rsDateGroup['date']; ?></td>
  </tr>
  <tr>
    <td valign="top">NESTED REPEAT REGION GOES HERE</td>
  </tr>
  <?php } while ($row_rsDateGroup = mysql_fetch_assoc($rsDateGroup)); ?>
  </table>

Open in new window

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 7

Expert Comment

by:Jonah11
ID: 24376861
sirnutty,

i still can't tell what you are trying to do.  what is the data supposed to look like?  can you type out some 2 - 3 samples rows with sample data?
0
 

Author Comment

by:sirnutty1
ID: 24378686
Hi Jonah11

Many thanks for your post.

I am in the process of building a student tracking application for a martial arts school. This report is specifically returning data with regards to monthly gradings (examinations) that the students do.

Eachd month a certain number of students are entered into the database as 'ready to grade'. These gradings normally occur over a four day period and on random weeks.

I have already generated a report that lists all students grading within a certain month which is displayed by day order. What i woud like to do is break the days of the month up. For example.

2009-05-13
Student 1
Student 6
Student 12

2009-05-15
Student 5
Student 3
Student 25

2009-05-17 etc..

To try and accomplish this I am trying to use a nested region.

I have created a recordset that returns a list of all students grading in a specified month, grouped by the day. The data returned gives me:

2009-05-13
2009-05-15
2009-05-17 etc...

Now I have the days that each grading is taking place, I need to  create a further recordset that uses the date values form the first recordset to return a list of student details. This list would then be nested beneath the values returned by the first recordset to produce the desired reult.

Thanks again for your help.
0
 
LVL 7

Accepted Solution

by:
Jonah11 earned 500 total points
ID: 24378845
for simplicity i am ignoring tables and just trying to get working output.  see if this works:
<?php do { ?>
	<b><?php echo $row_rsDateGroup['date']; ?></b><br />
	<?php do { ?>
		<?php echo $row_rsGradersTest['firstName']; ?> <?php echo $row_rsGradersTest['lastname']; ?><br />
		<?php } while ($row_rsGradersTest = mysql_fetch_assoc($rsGradersTest)); ?>
		<br/><br/>
<?php } while ($row_rsDateGroup = mysql_fetch_assoc($rsDateGroup)); ?>

Open in new window

0
 

Author Comment

by:sirnutty1
ID: 24389061
Many thanks Jonah11 and sorry for the delay. Will give this a try and get back to you.
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
clicking to find my folders on wamp 8 47
MySQL_Development_Traininng.. 10 20
syntax error, unexpected end of file 4 19
Phone number mask 4 16
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question