[PHP-DB] Array loops

2003-03-06 Thread Robin Sanchez
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 p1. 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 P2. 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



[PHP-DB] Re: Array loops

2003-03-06 Thread Robin Sanchez
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 p1. $description : $date_done;
}
}

That should do all that u want
It will list all exam times that meet your search.

Joel Colombo



Robin Sanchez [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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 p1. 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 P2. 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