I need a script that will enter the current date and time into a mySQL database and then output it in a certain format. The reason i'm doing this is to enter the date into the <pubDate></pubDate> field of my RSS feed.
For the first part there is a form where the administrator enters the information to be put in the database which is:
The information is then entered into the database. The database has the following fields:
The data is then output in repeating tables with the following code
The output should look like this
eg
Maybe we could use Datestamp or Timestamp to get the current date & time so it automatically gets entered into the news_time field then parse the string when it's called from the database?
For the first part there is a form where the administrator enters the information to be put in the database which is:
- News title
- News text
The information is then entered into the database. The database has the following fields:
- news_id <-- This is entered automatically with auto_increment
- news_title <-- Enetered via the form
- news_text <-- Entered via the form
- news_time <-- This is the part i'm stuck on
- news_posterid <-- todo later
The data is then output in repeating tables with the following code
| Code: |
| <?
$query = "SELECT * FROM news ORDER BY news_id DESC LIMIT 0,5"; $numqueries++; $result=mysql_query($query) or die ( mysql_error( ) ); mysql_close(); while($row = mysql_fetch_row($result)) { $news_id = $row[0]; //use row names for simplicity $news_title = $row[1]; $news_text = nl2br($row[2]); $news_time = $row[3]; ?> <table width="100%" border="0" cellspacing="0" cellpadding="3" class="border1"> <tr> <td class="cellpic2"><div><span class="title"><? echo "$news_title"; ?></span> - <span class="tiny"><? echo "$news_time"; ?></span></div></td> </tr> <tr> <td><p><? echo "$news_text"; ?></p></td> </tr> </table><br /> <? } ?> |
The output should look like this
| Code: |
| Day, month date, year time |
eg
| Code: |
| Thu, Apr 6, 2006 11:55 |
Maybe we could use Datestamp or Timestamp to get the current date & time so it automatically gets entered into the news_time field then parse the string when it's called from the database?
