divadiva Posted August 4, 2008 Share Posted August 4, 2008 Experts I am parsing data from xyz website.Whenever I run the parsing program ,new captured data is added along with that "date" field in the database is updated to the current date. I want to see date field in the php page ,which will display the data when first time website was parsed. Here is my table in database: CREATE TABLE `data` ( `iddata` bigint(20) NOT NULL auto_increment, `firstdatecaptured` timestamp NOT NULL default CURRENT_TIMESTAMP, `date` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`iddata`) ) ; Here is my PHP file which displays data: <?php if(isset($_GET['idsite'])) { $idsite = 0; $idsite = $_GET['idsite']; if($idsite == 'All') { $res = executeAllRecords("select *, date(date) as curdate from data order by iddata"); echo '<h3 style="color:#64E986"> Data from all sites</h3>'; } else { $res = executeAllRecords("select *, date(date) as curdate from data where site='".$idsite."' order by iddata"); echo '<h3 style="color:#64E986"> Data from site: ' . $idsite.'</h3>'; } echo '<br clear = "both"/>'; echo '<br clear = "both"/>'; echo '<br clear = "both"/>'; } else { echo "Select a website to be displayed "; echo "<ul> <li><a href=\"showdata.php?idsite=All\">All sites</a></li> <li><a href=\"showdata.php?idsite=XYZ\">xyz.com</a></li> } if(mysql_num_rows($res) == 0) return; echo '<table cellspacing="1" border="1"> <tr> <th>WebsiteId </th> <th>Data captured</th> <th>FirstDateCaptured</th> </tr> '; while($row = mysql_fetch_array($res)) { $printRow = ''; $count = 0; $printRow .= printColumn($row['WebsiteId']); $printRow .= printColumn($row['curdate']); $printRow .= printColumn($row['FirstDateCaptured']); echo '<tr>'.$printRow.'</tr> '; } echo '</table>'; function printColumn($colValue) { return '<td>'.$colValue.'</td>'; } include("footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/118091-date-in-php/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.