Create Account
Sign In

Validate code

To create and answer topics, you must to be logged.
Pages: 1
Author Message
21/05/2014 at 19:27:46

Select database based on current day and time
Please help me to correct this code:

I want to fetch data from my DATABASE and i want to pick the last post alone. That is the current Post
Here is the code i used. I don't want all data to be selected just the latest news.


//Sanitize the POST values
$subject = $_POST['subject'];
$detail = $_POST['detail'];

//Create a connection to table
include "config.php";

/*show table*/
$result =mysql_query("SELECT *FROM prayer WHERE subject = 'news' CURDATE()");

echo "<table border='0' cellpadding='2' cellspacing='3'>
<tr >
<th bgcolor='#99CCCC'>ANNOUNCEMENT & GOOD NEWS</th>


while($row = mysql_fetch_array($result))
echo "<tr>";
echo "<td bgcolor='#99FF66' width ='378' height ='100' align='justify'>" . $row['details'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#CCCCFF' width ='378' height ='20' align='right'>" . $row['Date'] . "</td>";
echo "</tr>";

echo "</table>";

if($result) {
echo "Updates Records <a href=updates.php>here</a>";
else {
die("Query failed");

This is the error that keeps coming.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\cody\events.php on line 20

Please help
Report Quote Reply

Pages: 1