Code:
$result = mysql_query("
SELECT
*,
DATE_FORMAT(call_start,'$dateformat2') as fcall_start
FROM
call_notes
WHERE
ticketid='$reviewticketid'
ORDER BY
$sql_order
",$dbx);
while ($row = mysql_fetch_array($result)) {
$noteid = $row[noteid];
$result2 = mysql_query("SELECT note_text FROM call_notes_text WHERE noteid='$noteid'",$dbx);
$row2 = mysql_fetch_array($result2);
$note_text = stripslashes($row2[note_text]);
$note_text = nl2br($note_text);
$checkuserid = $row[userid];
$result3 = mysql_query("SELECT username, email FROM users WHERE userid='$checkuserid'",$dbx);
$row3 = mysql_fetch_array($result3);
$username_notes = $row3[username];
$email = $row3[email];
$call_contact = $row[call_contact];
$result3 = mysql_query("SELECT contact FROM facility_contact WHERE contactid='$call_contact'",$dbx);
$row3 = mysql_fetch_array($result3);
$contact = $row3[contact];
$call_elapsed = $row[call_elapsed];
This section hasn't sat well with me ever since I wrote it. It works, but I am interested in combining these 4 queries into one.
My problem is that the 'child' queries are dependant on data pulled out of the first table (call_notes).
Help is greatly appreciated.
Thanks, Mike