PHP Classes

PHP MYSQL Date

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  PHP MYSQL Date  
Subject:PHP MYSQL Date
Summary:Problem with Date
Messages:5
Author:chris
Date:2009-11-27 18:54:53
Update:2009-12-04 10:07:51
 

  1. PHP MYSQL Date   Reply   Report abuse  
Picture of chris chris - 2009-11-28 01:42:47
this code below is causing me problems which l still have not been able to solve the problem.

THis is a form that user will edit his input after the other form is submitted.

The problem is, even if the user did not enter any dates, anytime the edit form is open, there is a wrong date which stats from 1999.11.30


This is causing me headdache and have not got a clue to allow the date either to have the present date or not to show. If this 1999 appears, saving after editing is not possible unless this date is earesd. Trying to make this formular user friendly, any help will help me...

Please any help will be much appreciated.

Thank you.-------------->


$result = my_sql_query("SELECT date_on, date_off FROM navi WHERE nid=$sel AND is_campaign IS NOT NULL","");
if(!isset($result[0])) {
$dateon = $result[1][0]['date_on'];
$dateoff = $result[1][0]['date_off'];
if($lang == "ger") {
if(!empty($dateon)) {
$on = explode("-", $dateon);
if(count($on) == 3)
$dateon = date("d.m.Y", mktime(0, 0, 0, $on[1], $on[2], $on[0]));
}
if(!empty($dateoff)) {
$off = explode("-", $dateoff);
if(count($off) == 3)
$dateoff = date("d.m.Y", mktime(0, 0, 0, $off[1], $off[2], $off[0]));
}
} else {
if(!empty($dateon)) {
$on = explode("-", $dateon);
if(count($on) == 3)
$dateon = date("Y-m-d", mktime(0, 0, 0, $on[1], $on[2], $on[0]));
}
if(!empty($dateoff)) {
$off = explode("-", $dateoff);
if(count($off) == 3)
$dateoff = date("Y-m-d", mktime(0, 0, 0, $off[1], $off[2], $off[0]));
}
}
} else {
echo $result[0];
}

echo "<tr align ='center'>\n"
."<td width='10%'></td>\n"
."<td width='70%'>"._FROM."&nbsp;<input name='startdate' type='text' value='$dateon' size='15' maxlength='10'>&nbsp;&nbsp;"._TO."&nbsp;<input name='enddate' type='text' value='$dateoff' size='15' maxlength='10'</td>\n"
."<td width='5%'></td>\n"
."</tr>\n"
."<tr align ='center'>\n"
."<td width='10%'></td>\n"
."<td width='70%' ><br /><input type='submit' name='save' value='"._SAVE."' id='button'>&nbsp;&nbsp;<input type='submit' name='reset3' value='"._RESET."' id='button'></td>\n"
."<td width='5%'></td>\n"
."</tr>\n";
echo "</table><br /></td></tr></table><br /><br />\n"
."</div>\n"
."</form>\n";
echo "<script>document.form1.title.focus();</script>\n";

There are 4 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.