|
|
|
ทำ Date diff เทียบข้อมูลจาก DB มัน Fatal error: Cannot redeclare datediff() |
|
|
|
|
|
|
|
function datediff() มันมาจากไหนครับ
Fatal error: Cannot redeclare datediff()
|
|
|
|
|
Date :
2011-07-28 21:57:11 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หรือไม่ลองดูตัวนี้ครับ
Code (PHP)
<?php
function DateDiff($strDate1,$strDate2)
{
return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24
}
function TimeDiff($strTime1,$strTime2)
{
return (strtotime($strTime2) - strtotime($strTime1))/ ( 60 * 60 ); // 1 Hour = 60*60
}
function DateTimeDiff($strDateTime1,$strDateTime2)
{
return (strtotime($strDateTime2) - strtotime($strDateTime1))/ ( 60 * 60 ); // 1 Hour = 60*60
}
echo "Date Diff = ".DateDiff("2008-08-01","2008-08-31")."<br>";
echo "Time Diff = ".TimeDiff("00:00","19:00")."<br>";
echo "Date Time Diff = ".DateTimeDiff("2008-08-01 00:00","2008-08-01 19:00")."<br>";
?>
Go to : PHP DateDiff / TimeDiff
|
|
|
|
|
Date :
2011-07-28 21:58:06 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา function DateDiff($i,$x) ออกมานอก while loop ครับ
|
|
|
|
|
Date :
2011-07-29 00:14:46 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อืม ๆๆๆ อสบัสนกับ Error message ครับ Cannot redeclare แปลว่าประกาศซ้ำ
|
|
|
|
|
Date :
2011-07-29 06:09:17 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ป่าวครับ ผมทำแบบนี้2หน้าเเล้ว include มารวมกัน มันเลยชนกัน วิธีเเก้คือลบอันใดอันนึ่ง
เเบ่งปันครับ ใครสนใจลองทำได้
Code (PHP)
<?php include('connect.php');
$i = date("Y-m-d");
$sql = " select * from tb_movie order by m_date_in DESC";
$query = mysql_query($sql);
$cols = 0;
$auto=1;
$c = $cols;
function DateDiff($i,$x) <<<ตัวปห ^^
{
return (strtotime($x) - strtotime($i))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24
}
while($db= mysql_fetch_array($query))
{
$x = $db[m_date_in];
if(DateDiff($i,$x)<=0)
{
if($auto<6)
{
$auto++;
$c--;
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<td width="" align="center" valign="top"><table width="105" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="105" height="118" align="center" valign="middle" class="hovergallery"><img src="<?php echo $db[m_iposter] ?>" width="128" height="178" border="0" title="<?php echo $db[m_name_en]; ?>" /></td>
</tr>
<tr>
<td width="105" height="30" align="center" valign="top"><a href="<?php echo "movie_room.php?m_id=".$db[m_id].""; ?>" target="_blank"><img src="img/etc/watch_trailer.png" width="128" height="25" border="0" /></a></td>
</tr>
<tr>
<td align="center"><a href="<?php echo "movie_room.php?m_id=".$db[m_id].""; ?>" target="_blank">
<?php echo $db[m_name_short]; ?>
</a></td>
</tr>
</table></td>
<?php }
if($c == 0) {
$c = $cols;
echo "</tr>";
}}
else
{
//echo "show";
}
}
//echo "</table>";
?>
ขอบคุณพี่ๆมากครับ
|
|
|
|
|
Date :
2011-08-05 01:32:37 |
By :
skmbz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|