Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Nested Repeat Region - Dreamweaver CS4 - PHP - MySQL

Posted on 2009-05-12
7
Medium Priority
?
1,440 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
  • 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

876 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