Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Nested Repeat Region - Dreamweaver CS4 - PHP - MySQL

Posted on 2009-05-12
7
Medium Priority
?
1,429 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
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

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.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

688 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