flemingmike Posted September 23, 2011 Share Posted September 23, 2011 hi, i have a select which gets todays schedule for each user. sometimes that user doesnt have anything for todays date and it will display the info from the user above him. how can i make it so it stays blank if there is no record? Quote Link to comment https://forums.phpfreaks.com/topic/247721-if-doesnt-exist/ Share on other sites More sharing options...
Pikachu2000 Posted September 23, 2011 Share Posted September 23, 2011 Check if the user doesn't have anything for today's date, and if not, don't echo anything. Quote Link to comment https://forums.phpfreaks.com/topic/247721-if-doesnt-exist/#findComment-1272106 Share on other sites More sharing options...
flemingmike Posted September 23, 2011 Author Share Posted September 23, 2011 im not sure if i need to rewrite for that. here is what i have. can u let me know if i can modify this, or if i should rewrite. $result = mysql_query("SELECT * FROM staff WHERE status = '1' ORDER BY name"); while($row = mysql_fetch_array($result)) { $id=$row['id']; $eid=$row['eid']; $name=$row['name']; $result4 = mysql_query("SELECT * FROM schedule WHERE date = '$date' AND eid = '$eid'"); while($row4 = mysql_fetch_array($result4)) { $sid=$row4['id']; $seid=$row4['eid']; $sdate=$row4['date']; $sjobnumber=$row4['jobnumber']; $sstarttime=$row4['starttime']; $sstatus=$row4['status']; if("$sstatus" == "1") { $sstatusout="<font color='#0000FF' size='4'>Waiting For Arival</font>"; } if("$sstatus" == "2") { $sstatusout="<font color='#00FF00' size='4'>Signed In</font>"; } if("$sstatus" == "3") { $sstatusout="<font color='#FF0000' size='4'>Signed Out</font>"; } $sdate1 = date( 'D M j', strtotime($sdate) ); $sstart1 = date( 'g:i A', strtotime($sstarttime) ); $shortid=substr($sjobnumber, 5, -1); //remove the first 5 characters and minus the last character } $result7 = mysql_query("SELECT * FROM timesheet WHERE schednum = '$sid'"); while($row7 = mysql_fetch_array($result7)) { $tsid=$row7['id']; $tdate=$row7['date']; $tjobnumber=$row7['jobnumber']; $teid=$row7['eid']; $tdescription=$row7['description']; $tsignin=$row7['start']; $tfinish=$row7['finish']; $tlunch=$row7['lunch']; $tkms=$row7['kms']; $tschednum=$row7['schednum']; $tdate1 = date( 'M j, Y', strtotime($tdate) ); $tsignin1 = date( 'g:i a', strtotime($tsignin) ); $tfinish1 = date( 'g:i a', strtotime($tfinish) ); if( empty($tfinish) ) { $tfinish2="<i>In Progress"; } else { $tfinish2="$tfinish1"; } if( empty($tfinish) ) { $tfinish2="<i>In Progress"; } else { $tfinish2="$tfinish1"; } } $result33 = mysql_query("SELECT * FROM jobs WHERE id = '$shortid'"); while($row33 = mysql_fetch_array($result33)) { $jcontact=$row33['contact']; $jcontactphone=$row33['contactphone']; $jaddress=$row33['address']; $jcity=$row33['city']; $jpostal=$row33['postal']; $jprovince=$row33['province']; $jcustomer=$row33['customer']; $jlocation="$jaddress $jcity $jpostal $jprovince"; } echo "<tr>"; echo "<td align='center'>" . $name . "</td>"; echo "<td align='center'>"; if ($sjobnumber == 1 ) { } else { echo "" . $sjobnumber . ""; } echo "</td>"; echo "<td align='center'>" . $sstart1 . "</td>"; echo "<td align='center'>"; if ($sstatus == 1 ) { } else { echo "" . $tsignin1 . ""; } echo "</td>"; echo "<td align='center'>"; if ($sstatus == 1 ) { } else { echo "" . $tfinish2 . ""; } echo "</td>"; echo "<td align='center'>" . $jcustomer . "</td>"; echo "<td align='center'><a target='_blank' href='http://mapof.it/" . $jlocation . "'>" . $jaddress . "</a></td>"; echo "<td align='center'>" . $sstatusout . "</td>"; } echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/247721-if-doesnt-exist/#findComment-1272109 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.