rashmi_k28 Posted March 26, 2008 Share Posted March 26, 2008 I have a code and I have to display the each table separately depending on the date. Suppose I have 3 dates, The records of each date should be displayed in separate table. Please tell me how to do it. $start_date = $_REQUEST["date1"]; $end_date = $_REQUEST["date2"]; $res_head="select distinct(date(timestamp) from `tablename` where date(timestamp) >='".$start_date."' date(timestamp) <= '".$end_date."' and status=0"; $res1=mysql_query($res_head); while($res=mysql_fetch_array($res1)){ //Some code array_push($records,"$result[2]#$ip[0]#$result[2]#$previoustime#$result[1]#$d"); <TABLE BORDER=2 CELLPADDING=4 width=\"100%\" bordercolor=\"#000000\"><TR><TH COLSPAN=2>DATE AS ON $start_date</TH><th COLSPAN=6>Status(Down)</th></TR><TR><TH COLSPAN=8> STATUS OF NETWORK</TH></TR><TR><TD>SL NO</TD><TD>CLIENT NAME</TD><TD>IP ADDRESS</TD><TD> NAME</TD><TD>START TIME</TD><TD>END TIME</TD><TD>DURATION in (days:hours:minutes)</TD></TR> Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/ Share on other sites More sharing options...
Lyleyboy Posted March 26, 2008 Share Posted March 26, 2008 By far the simplest way would be to just use three while loops. Just create an if statement to handle the number of dates. Job Done! Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501041 Share on other sites More sharing options...
rashmi_k28 Posted March 26, 2008 Author Share Posted March 26, 2008 The table should be separate. Give me some example Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501042 Share on other sites More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 <? $res_head="select distinct(date(timestamp) from `tablename` where date(timestamp) >='".$start_date."' date(timestamp) <= '".$end_date."' and status=0"; $res1=mysql_query($res_head); $data=""; while($res=mysql_fetch_array($res1)){ $data .='<table>'; $res2="select from table where date='$res[0]'"; while($res3=mysql_fetch_array($res2)) { $data .='<tr>'; $data .='<td>'.$res3[0].'</td>'; $data .='<td>'.$res3[1].'</td>'; $data .='</tr>'; } $data .='</table>'; } ?> Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501049 Share on other sites More sharing options...
rashmi_k28 Posted March 26, 2008 Author Share Posted March 26, 2008 Table is html script. Not the database table Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501056 Share on other sites More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 plz go through the code i am taking the distinct dates then i will start a new loop to take the details of the date each distinct date details will be shown in different table (HTML) if this is not your requirement, try to describe in details ??? Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501062 Share on other sites More sharing options...
rashmi_k28 Posted March 26, 2008 Author Share Posted March 26, 2008 Hi, Thanks for your reply. I want the code where based on the date the output for a particular date should form a separate table <table> Date 1 information </table> <br> <table> Date 2 information </table> Like this for the number of date the table should be dispalyed Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501080 Share on other sites More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 thats what the above code will do :o :o <? selecting the distinct dates $res_head="select distinct(date(timestamp) from `tablename` where date(timestamp) >='".$start_date."' date(timestamp) <= '".$end_date."' and status=0"; $res1=mysql_query($res_head); $data=""; while($res=mysql_fetch_array($res1)){ STARTING THE TABLE OPENING $data .='<table>'; GETTING THE INFORMATION OF THAT DATE FROM OTHER TABLE , YOU CAN SKIP THIS IF YOU WANT $res2="select from table where date='$res[0]'"; while($res3=mysql_fetch_array($res2)) { $data .='<tr>'; $data .='<td>'.$res3[0].'</td>'; $data .='<td>'.$res3[1].'</td>'; $data .='</tr>'; } CLOSING THE TABLE AFTER EACH DATE $data .='</table>'; } ?> Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501085 Share on other sites More sharing options...
ansarka Posted March 26, 2008 Share Posted March 26, 2008 AND IF YOU WANT TO PRINT USE THE FUNCTION ECHO $DATE Link to comment https://forums.phpfreaks.com/topic/97934-each-table-datewise/#findComment-501086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.