Jump to content

calling function within function problem


will35010

Recommended Posts

I'm having a problem calling function 2 from within function 1. In function 1 $row['REG_TIME'] returns a timestamp. Function 2 calculates the hours and minutes. It will show for the first row in a weird spot and it then it won't show for any other lines. Any help would be appreciated. Thanks!  :D

 

Function 1:

//function to create triage view table
function getTriageList() {
require('db.php');
$sql = mysqli_query($conn, "SELECT lobby.MRN, pt_status.PATIENT_LAST_NAME, pt_status.PATIENT_FIRST_NAME, pt_status.AGE, pt_status.SEX, pt_status.CC, pt_status.CCOTHER, pt_status.CURRENT_STATUS, pt_status.REG_TIME FROM lobby, pt_status WHERE lobby.MRN = pt_status.MRN");
while($row = mysqli_fetch_array($sql)) {
echo "<table width='95%' border='2'>
          <tr>
           <td width='15%' bgcolor='#FFFFFF'>".$row['PATIENT_LAST_NAME']."</td>
            <td width='15%' bgcolor='#FFFFFF'>".$row['PATIENT_FIRST_NAME']."</td>
            <td width='8%' bgcolor='#FFFFFF'>".$row['AGE']."</td>
            <td width='8%' bgcolor='#FFFFFF'>".$row['SEX']."</td>
            <td width='6%' bgcolor='#FFFFFF'>".$row['CC']."</td>
            <td width='6%' bgcolor='#FFFFFF'>".$row['CCOTHER']."</td>
            <td width='21%' bgcolor='#FFFFFF'>".$row['CURRENT_STATUS']."</td>
            <td width='20%' bgcolor='#FFFFFF'>".getTIME($row['REG_TIME'])."</td>
          </tr>
        </table>
        <p><str";
}	
}

 

Function 2:

function getTIME($time) {
//start/end dates
$startdate = $time;
$enddate = time();

//difference between the two in seconds
$time_period = ( $enddate - $startdate );

$minutes=floor($time_period/60); 
$hours=floor($minutes/60); 

if($hours==1) { 
$hoursdisplay=$hours; 
} 
if(($minutes%60) > 1) { 
$minutesdisplay=($minutes%60); 
}
else if(($minutes%60)==1) { 
$minutesdisplay=($minutes%60);
} 
else { $minutesdisplay=""; 
} 
$display=$hours.":".$minutesdisplay; 

echo $display;
}

 

HTML source of output:

      <td width="75%" align="center" valign="top" bgcolor="#FF33CC"><p><strong>Triage View</strong></p>
        38:39<table width='95%' border='2'>
          <tr>
           <td width='15%' bgcolor='#FFFFFF'>tester</td>
            <td width='15%' bgcolor='#FFFFFF'>testes</td>
            <td width='8%' bgcolor='#FFFFFF'>30</td>

            <td width='8%' bgcolor='#FFFFFF'>Male</td>
            <td width='6%' bgcolor='#FFFFFF'>Chest Pain</td>
            <td width='6%' bgcolor='#FFFFFF'></td>
            <td width='21%' bgcolor='#FFFFFF'>Waiting on Room</td>
            <td width='20%' bgcolor='#FFFFFF'></td>
          </tr>
        </table>

        <p><str22:49<table width='95%' border='2'>
          <tr>
           <td width='15%' bgcolor='#FFFFFF'>Morris</td>
            <td width='15%' bgcolor='#FFFFFF'>William</td>
            <td width='8%' bgcolor='#FFFFFF'>30</td>
            <td width='8%' bgcolor='#FFFFFF'>Male</td>
            <td width='6%' bgcolor='#FFFFFF'>Chest Pain</td>

            <td width='6%' bgcolor='#FFFFFF'></td>
            <td width='21%' bgcolor='#FFFFFF'>Waiting on Room</td>
            <td width='20%' bgcolor='#FFFFFF'></td>
          </tr>
        </table>
        <p><str22:7<table width='95%' border='2'>
          <tr>
           <td width='15%' bgcolor='#FFFFFF'>morris</td>

            <td width='15%' bgcolor='#FFFFFF'>will</td>
            <td width='8%' bgcolor='#FFFFFF'></td>
            <td width='8%' bgcolor='#FFFFFF'></td>
            <td width='6%' bgcolor='#FFFFFF'>Chest Pain</td>
            <td width='6%' bgcolor='#FFFFFF'></td>
            <td width='21%' bgcolor='#FFFFFF'>Waiting on Room</td>
            <td width='20%' bgcolor='#FFFFFF'></td>

          </tr>
        </table>
        <p><str        <p><strong></strong></p>
      <p> </p></td>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.