ankycooper Posted September 25, 2006 Share Posted September 25, 2006 hi i have a database in which there are following fieldsnamemonthstartdateenddatestarttimeendtimewf1wf2wf3lets take a sample datajay petermarch2006-09-032006-09-2407:0016:00SaturdaySundayNAthere are sevral such recordsi want to populate a table like this (see the attachment)Need some help[attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/ Share on other sites More sharing options...
steveclondon Posted September 25, 2006 Share Posted September 25, 2006 Do you mean export to excel or just display in the browser in a table. Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98329 Share on other sites More sharing options...
ankycooper Posted September 25, 2006 Author Share Posted September 25, 2006 Populate as a table in the browserPlease Help Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98387 Share on other sites More sharing options...
Barand Posted September 25, 2006 Share Posted September 25, 2006 You just need to output 2 HTML table rows for each record in the db table[code]<tr><td rowspan='2'>$date</td> <td rowspan='2'>$day</td> <td>Office reporting</td> <td>$time1</td></tr><tr> <td>Office departing</td> <td>$time2</td></tr>[/code] Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98416 Share on other sites More sharing options...
craygo Posted September 25, 2006 Share Posted September 25, 2006 Try this[code]<table width=800 align=center border=1> <tr> <td width=150>Date</td> <td width=150>Day</td> <td width=300>Time</td><?php$sql = "SELECT * FROM table_name"; $res = mysql_query($sql) or die (mysql_error()); $r = mysql_fetch_assoc($res); echo "<td width=200>".$r['name']."</td></tr>"; $days = (date("j", strtotime($r['enddate'])) - date("j", strtotime($r['startdate']))) + 1; $startdate = date("Y-m-d", strtotime($r['startdate'])); for($i=0; $i<$days; $i++){ $day = date("D", strtotime($startdate)); $fullday = date ("l", strtotime($startdate)); if($fullday == $r['wf1'] || $fullday == $r['wf2'] || $fullday == $r['wf3']){ $st_time = "WOFF"; $e_time = "WOFF"; } else { $st_time = $r['starttime']; $e_time = $r['endtime']; } echo "<tr>"; echo "<td rowspan=2>$startdate</td>"; echo "<td rowspan=2>$day</td>"; echo "<td>Start time</td>"; echo "<td>$st_time</td>"; echo "</tr>"; echo "<tr>"; echo "<td>End Time</td>"; echo "<td>$e_time</td>"; echo "</tr>"; $startdate = date("Y-m-d", strtotime("$startdate +1 day")); } echo "</table>";?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98440 Share on other sites More sharing options...
ankycooper Posted September 25, 2006 Author Share Posted September 25, 2006 Still No Good Does Any one Knows How To Do It Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98446 Share on other sites More sharing options...
craygo Posted September 25, 2006 Share Posted September 25, 2006 Works fine for me based on your info up top.Ray Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-98450 Share on other sites More sharing options...
ankycooper Posted September 27, 2006 Author Share Posted September 27, 2006 This Code Works For ME But it only shows the 1st record and does not populate all of them[code]<html><link rel="stylesheet" type="text/css" href="../scripts/main.css" ><head><title>Roster Management System</title></head><body bgcolor="#C7E1F4"><div align="center"> <center><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#EEEEEE"> <tr style="font-size: 12px; color: #ffffff; font-family: Arial, Helvetica, sans-serif"> <td class="info" style='border:1px solid #C7E1F4; background-color: #2955B5' width="100" height="1"> <p align="left"><b><font color='#FFFFFF'> Date </font></b></td> <td class="info" style="border:1px solid #C7E1F4; background-color: #2955B5" width="65" height="1"> <p align="left"><b><font color='#FFFFFF'> Day </font></b></td> <td class="info" style="border:1px solid #C7E1F4; background-color: #2955B5" width="100" height="1"> <p align="left"><b><font color='#FFFFFF'> Time </font></b></td><?phpfunction dateconvert($date,$func) { if ($func == 1){ //insert conversion list($day, $month, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$day/$month/$year"; return $date; }}$mmyy=$_GET['mmyy'];include '../config/dbinfo.inc.php';@mysql_connect($host,$user_name,$pass_word);@mysql_select_db($database) or die( "Unable to select database");$sql = "SELECT * FROM emproster where mmyy='$mmyy'"; $sql = "SELECT * FROM emproster where mmyy='$mmyy'"; $res = mysql_query($sql) or die (mysql_error()); $r = mysql_fetch_assoc($res); echo "<td class='info' style='border:1px solid #C7E1F4; background-color: #2955B5' width='150' height='1'> <p align='left'><b><font color='#FFFFFF'> ".$r['name']."</font></b></td>"; echo "</tr>"; $days = (date("j", strtotime($r['edate'])) - date("j", strtotime($r['sdate']))) + 1; $sdate = date("Y-m-d", strtotime($r['sdate'])); for($i=0; $i<$days; $i++){ $day = date("D", strtotime($sdate)); $fullday = date ("l", strtotime($sdate)); if($fullday == $r['wf1']) { $st_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; $e_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; } elseif($fullday == $r['wf2']) { $st_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; $e_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; } elseif($fullday == $r['wf3']){ $st_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; $e_time = "<span style='background-color: #FF0000'><b><font color='#FFFFFF'> WOFF </font></b></span>"; } else { $st_time = "<b><font color='#2955B5'><span style='background-color: #FFFF99'> ".$r['stime']." </span></font></b>"; $e_time = "<b><font color='#2955B5'><span style='background-color: #CCFF99'> ".$r['etime']." </span></font></b>"; } $sdate=dateconvert($sdate, 1); echo "<tr>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF' rowspan=2><b><font color='#2955B5'> $sdate</b></font></td>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF' rowspan=2><b><font color='#2955B5'> $day</b></font></td>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF'><b><font color='#2955B5'> Report Time</b></font></td>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF'>$st_time</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF'><b><font color='#2955B5'> Drop Time</b></font></td>"; echo "<td class='back2' style='border:1px solid #C7E1F4; background-color: #CED7EF'>$e_time</td>"; echo "</tr>"; $sdate = date("Y-m-d", strtotime("$sdate +1 day")); } echo "</table>";?> </center></div>[/code] Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-99522 Share on other sites More sharing options...
ankycooper Posted October 1, 2006 Author Share Posted October 1, 2006 Please Help Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-101713 Share on other sites More sharing options...
ankycooper Posted October 1, 2006 Author Share Posted October 1, 2006 I Think no one is a real Guru Who can solve this Link to comment https://forums.phpfreaks.com/topic/21988-date-sheet-population/#findComment-101842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.