Thanks that works like a charm and I learned some tricks that I can apply to some other code!!! Ozzie Hi there. here ya go. $array_of_exams = Array(); $array_of_exams['Full Head'] = 'Head Examination History'; $array_of_exams['Full Body'] = 'Body Examination History'; $array_of_exams['Full Butt'] = 'Butt Examination History'; $exam_dates = Array(); foreach ($array_of_exams as $exam => $description) { $neh="select * from pro_list, complete_pro where pro_list.pro_name ='$exam' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'"; $resneh=safe_query($neh); $exam_count = 0; while ($rown=mysql_fetch_array($resneh)){ $exam_dates[$exam][$exam_count] = $rown['compl_date']; $exam_count++; } } foreach ($array_of_exams as $exam => $description) { foreach ($exam_dates[$exam] as $date_done) { echo "<p>1. $description : $date_done"; } } That should do all that u want.... It will list all exam times that meet your search. Joel Colombo "Robin Sanchez" <rgsanchez@ucdavis.edu> wrote in message BA8CC163.537F%rgsanchez@ucdavis.edu">news:BA8CC163.537F%rgsanchez@ucdavis.edu... > I am creating a results page for completed and uncompleted procedures. I am > repeating a lot of the code and wonder if there is an easier way to do this. > $neh="select * from pro_list, complete_pro where pro_list.pro_name > ='Neurological Exam/History' > and complete_pro.proid=pro_list.proid > and complete_pro.sysid='$sysid' > and complete_pro.transid='$transid'"; > $resneh=safe_query($neh); > while ($rown=mysql_fetch_array($resneh)){ > $compl_date1=$rown['compl_date']; > } > echo "<p>1. Neurological Exam and History $compl_date1"; > > $neh="select * from pro_list, complete_pro where pro_list.pro_name ='Ankle > Arm BP Measurement' > and complete_pro.proid=pro_list.proid > and complete_pro.sysid='$sysid' > and complete_pro.transid='$transid'"; > $resneh=safe_query($neh); > while ($rown=mysql_fetch_array($resneh)){ > $compl_date2=$rown['compl_date']; > } > echo "<P>2. Ankle/Arm BP Measurement $compl_date2"; and so on and so on... > > It seems that I could use a 'for' loop in the searches, but how do I > populate the result fields (some of which will be empty) with the > appropriate tests. > Any thoughts. > Ozzie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php