Hi,
This is my first post.. I hope someone can understand me and help..
I am building a dynamic php form (with mysql) with parent-child relationship.. The form should be like:
Parent_id Parent_descrition
child_col1 child col2
child_col1 child_col2
Parent_id Paren_description
child_col1 child_col2
etc...
I am successful with the first set of parent_child rows, then my next parent shows and I do not get the matching children..
I think I need to reset something after the child while loop, but I'm not sure what or how....here is a copy of the php code::
<?php
mysql_select_db($database_connsurvey, $connsurvey);
$query_sets_records = "SELECT title, description FROM webinar_master";
$sets_records = mysql_query($query_sets_records, $connsurvey) or die(mysql_error());
$row_sets_records = mysql_fetch_assoc($sets_records);
$totalRows_sets_records = mysql_num_rows($sets_records);
$query_sets_child =
"SELECT date, time, title FROM webinar_schedule
where title= " ."'". $row_sets_records['title']."'";
$sets_child = mysql_query($query_sets_child, $connsurvey) or die(mysql_error());
$row_sets_child = mysql_fetch_assoc($sets_child);
$totalRows_sets_child = mysql_num_rows($sets_child);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">Title </th>
<th scope="col">Description</th>
</tr>
<?php do { ?>
<tr>
<td> <hr /> </td>
<td> <hr /> </td>
</tr>
<tr>
<td><?php echo $row_sets_records['title']; ?></td>
<td><?php echo $row_sets_records['description']; ?></td>
</tr>
<!--This is the child table / date time -->
<tr>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">Date </th>
<th scope="col">Time</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo "parent title " . $row_sets_records['title']?>
<?php echo "child title " . $row_sets_child['title']?>
<?php echo "rows" . $totalRows_sets_child ?>
<?php echo $row_sets_child['date']; ?></td>
<td><?php echo $row_sets_child['time']; ?></td>
</tr>
<?php } while ($row_sets_child = mysql_fetch_assoc($sets_child)); ?>
</table>
</tr>
<!--end child table -->
<?php } while ($row_sets_records = mysql_fetch_assoc($sets_records)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($sets_records);
?>
<?php
mysql_free_result($sets_child);
?>
Thanks for some assistance in this matter..
Angela