Nested Repeat Region - Dreamweaver CS4 - PHP - MySQL

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

sirnutty1Asked:
Who is Participating?
 
Jonah11Connect With a Mentor Commented:
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
 
Jonah11Commented:
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
 
dhobaleCommented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
sirnutty1Author Commented:
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
 
Jonah11Commented:
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
 
sirnutty1Author Commented:
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
 
sirnutty1Author Commented:
Many thanks Jonah11 and sorry for the delay. Will give this a try and get back to you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.