You've basically got to 2 ways to go.
a) Do 2 selects. Get the contact, then get the rows of contact info. Display the contact, loop through the array of contact info records.
Pseudocodish ...
PHP Code:
$qry1 = "select name from users where id = 23";
$qry2 = "select datetime, message from messages where user_ref=23";
echo $qry1['name'];
foreach($qry2 as $row){
echo $row['datetime'] . ' ' . $row['message'] . PHP_EOL ;
}
b) Do 1 select. Get the contact multiple times, once for each of the rows of contact info -- then have PHP loop through all the rows but display only one row for the contact and then display all of the contact info records.
Pseudocodish also ...
PHP Code:
$qry = "select name, datetime, message from messages left joins users on users.id=messages.user_ref AND user_ref=23";
$count = 0;
foreach($qry as $row){
if( $count === 0){
echo $row['name'] . PHP_EOL ;
}
echo $row['datetime'] . ' ' . $row['message'] . PHP_EOL ;
$count++;
}
Bookmarks