Table: cquestions
cqid, cqtext, showdate.
I want to update 'showdate' field to tomorrows date..
database:
the code will display q1. i want to update the 2nd row only to
so, tomorrow q2 will be displayed and the third
row will be updated as
this code update the next row, but the problem is its executed every time page loads and update the next row... i want to execute the update query only once for the day. how to do it?
cqid, cqtext, showdate.
I want to update 'showdate' field to tomorrows date..
database:
Code:
cqid cqtext showdate 200 q1 2013-05-22 201 q2 0000-00-00 202 q3 0000-00-00
Code:
201 q2 2013-05-23
row will be updated as
Code:
202 q3 2013-05-24
Code:
<?php
$today=date("Y/m/d");
$tomorrow= date("Y-m-d", strtotime("tomorrow"));
echo "<form method='post' id='submit' action='checkresult.php'>";
$sql="SELECT * FROM cquestions where showdate= '$today' limit 1";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$cqid=mysql_result($result,"cqid");
$update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 1";
mysql_query($update1);
echo "<p>" . $row['cqtext'] . "</p>";
$sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
$result2=mysql_query($sql2);
while($row2=mysql_fetch_assoc($result2)){
echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext']; }
/*echo "<input type='hidden' name='email' value='email' />";*/
}
echo"<input type='submit' id='submit' name='submit' value='Submit Answers' />";
echo "</form>";
?>
Comment