Hi Everyone, I have a bit of a problem with printing out an array. The array is created from an aggregate query from two different tables. The resulting output (printed to the screen) has all of the right data but each column of data is offset by the column before it. In other words, none of the data is lining up horizontally. Please see code below:
<?php
$link = mysqli_connect("myhost", "steve_large", "mypassword", "mydatabase");
/ check connection /
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/make aggregate query statements/
$query = "select concat(fname,' ',left(lname,1),'.')as fullname from wp_lvsz_evr_attendee where event_id=9;";
$query .= "select answer as belt from wp_lvsz_evr_answer,wp_lvsz_evr_attendee where wp_lvsz_evr_attendee.id=wp_lvsz_evr_answer.registration_id and wp_lvsz_evr_attendee.event_id=9 and question_id=42;";
$query .= "select answer as event from wp_lvsz_evr_answer,wp_lvsz_evr_attendee where wp_lvsz_evr_attendee.id=wp_lvsz_evr_answer.registration_id and wp_lvsz_evr_attendee.event_id=9 and question_id=43;";
$query .= "select answer as school from wp_lvsz_evr_answer,wp_lvsz_evr_attendee where wp_lvsz_evr_attendee.id=wp_lvsz_evr_answer.registration_id and wp_lvsz_evr_attendee.event_id=9 and question_id=41";
/ execute multi query /
if (mysqli_multi_query($link, $query)) {
do {
/ show result sets /
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_array($result)) {
echo
"<tr>
<td>{$row['fullname']}</td>
<td>{$row['belt']}</td>
<td>{$row['event']}</td>
<td>{$row['school']}</td>
</tr>";
}
}
/* print divider */
} while (mysqli_next_result($link));
}
/ close connection /
mysqli_close($link);
?>
I really appreciate any help that you could give in my situation as it is very close to being what I want other than the layout. I am hoping to use it as a template at some point and this is the last part that I require.
Thanks again,
Steve