sorry for the delayed response, i guess by this time, you've figured out a solution...
nway, perhaps line
if ($thisevent = $newevent) {
is the one causing u trouble, since the $newevent will be assigned to $thisevent, rather than comparing it.
Also, do you have a 'reset' porocedure for for your second query such as mysql_data_seek($result, 0) to set the record pointer to the first record for every iteration of the first loop?
Last, I think you could do a join here so that you'll only have one query. The example below is not the exact query you might be looking for, but try to manipulate it.
$query = "SELECT Table1.event, Table1.eventmax, Table2.name FROM Table1 LEFT JOIN Table2 ON Table1.event = Table2.event ORDER BY Table1.event, Table2.name";
$result = mysql_query($query, $db);
$curEvent = '';
$event_count = 1;
$name_count = 1;
$ret = '';
while (list($db_event, $db_max, $db_name) = mysql_fetch_row($result)) {
if ($db_event == $curEvent) {
$ret .= "$name_count. $db_name <br />";
}
else {
// new event
if ($name_count < $db_max && $curEvent != '') {
for($i = $name_count; $i <= $db_max; $i++) {
$ret .= "$i. ___________________<br />";
}
}
$name_count = 1;
$ret .= "<h1>$event_count. $db_event</h1>";
$ret .= "$name_count. $db_name<br />";
$event_count++;
}
$name_count++;
$curEvent = $db_event;
}