will35010 Posted December 1, 2009 Share Posted December 1, 2009 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! 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> Quote Link to comment https://forums.phpfreaks.com/topic/183608-calling-function-within-function-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 1, 2009 Share Posted December 1, 2009 The getTIME() function needs to return the value, not echo it. When you echo something in getTIME(), it is output immediately when getTIME() is called. Quote Link to comment https://forums.phpfreaks.com/topic/183608-calling-function-within-function-problem/#findComment-969115 Share on other sites More sharing options...
will35010 Posted December 1, 2009 Author Share Posted December 1, 2009 The getTIME() function needs to return the value, not echo it. When you echo something in getTIME(), it is output immediately when getTIME() is called. That was it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/183608-calling-function-within-function-problem/#findComment-969174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.