news post help
Posted: Sun Nov 27, 2005 5:31 am
Sami | Please use
This is driving me crazy, if anyone can help and point me in the right direction i will be very greatful
thanks in advance
Sami | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
hi guys,
I'm looking for some pretty basic help with my news post.
I just need someone that knows php to help me out with these php scripts
this is the script to input the information into the database newspost.php
It all wprks well but I need to be able to input a date that will be displayed as eg. Sun 26th Nov 2005 instead of the default date format.
And also I want the current date news or the next relevant date to be displayed and the old news to be removed from the post? I want to be able to enter a post for a day specified by the date I enter, no timestamping
this is the script to input the information into the database newspost.php, have a look and see if you can figure out any solutions to my problem?Code: Select all
<?
$db_host = "localhost";
$db_username = "my_username";
$db_password = "my_password";
$db_name = "my_database";
if ($submit) {
mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
$query = "INSERT INTO news (name, subject, message, date)
VALUES ('$name','$subject','$message','$date')";
mysql_query($query);
mysql_close();
echo "Thanks $name your message has been added";
}
?>
<form name="news" method="post" action="<? echo $PHP_SELF ?>">
<table align="center" cellpadding="6" cellspacing="0">
<tr>
<td>Date :</td>
<td><input type="text" name="date"></td>
</tr>
<tr>
<td>Name :</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Subject :</td>
<td><input type="text" name="subject"></td>
</tr>
<tr>
<td valign="top">Message :</td>
<td><textarea name="message" cols="30" rows="6"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Add" style="cursor:pointer"> <input type="reset" name="reset" value="Clear" style="cursor:pointer"></td>
</tr>
And the news.php file to display the results for which I want to be displayed from the current date onwards.
<?
$db_host = "localhost";
$db_username = "my_username";
$db_password = "my_password";
$db_name = "my_database";
mysql_connect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
$query = "SELECT name, subject, message, DATE_FORMAT(date, '%a %D %b')
FROM news order by date DESC";
$result = mysql_query($query);
echo "<br><center>";
while($r=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td bgcolor='#660000'><h10>// $r[date]<HR color='#FFFFFF'></td>";
echo date("d js M", strtotime($date));
echo "<tr>";
echo "<td bgcolor='#FFFFFF'><h10>// $r[subject]<HR color='#660000'></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#FFFFFF'>$r[message]<HR color='#660000'></h10></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#FFFFFF'>Posted By:
$r[name]</a> $r[date]<br><br><br></td>";
echo "</tr>";
}
echo "</table>";
?>This is driving me crazy, if anyone can help and point me in the right direction i will be very greatful
thanks in advance
Sami | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]