|
|
|
ช่วยหน่อยครับ คือผมต้องการ update สถานะ โดยอัตโนมัติ เช่น เมื่อเราเพิ่มหนังเข้าฐานข้อมูลโดยกำหนดdate 15/03/2555 ซึ่งวันปัจจุบันเป็นวันที่ 07/03/2555 |
|
|
|
|
|
|
|
Code (PHP)
mysql_query(" UPDATE FROM table_name SET Status = 'xx' WHERE CreateDate <= DATE_ADD(Now(),INTERVAL -15 DAY) AND Status = 'yy' ");
กำหรดเงื่อนไขเอาครับ
|
|
|
|
|
Date :
2012-03-07 06:47:31 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เด๋วลองทำดูนะครับ
|
|
|
|
|
Date :
2012-03-07 13:34:56 |
By :
sibsan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นี้คือโค้ดที่ผมทำขึ้น ผมควร update ที่ตรงไหนครับ ผมทำแล้ว งง
Code (PHP)
<?php
session_start();
if (!isset ($_SESSION['id_id']))
{
echo "<script> alert('กรุณาเข้าสู่ระบบ!!!'); window.location='../login.php'; </script>";
}
include("connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<LINK REL="SHORTCUT ICON" HREF="../img/5126050954_75749b9029.jpg">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>nantawan</title>
<script language = "JavaScript">
//**** List Amphur (Start) ***//
function Listmovie(SelectValue)
{
form1.movie.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.movie.options[form1.movie.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM movie ORDER BY mo_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = "<?=$objResult["mn_id"];?>";
strValue = "<?=$objResult["mo_id"];?>";
strItem = "<?=$objResult["mo_name"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
form1.movie.options[form1.movie.length]= myOption
}
<?
}
?>
}
</script>
<link href="../font/font.css" rel="stylesheet" type="text/css" />
<link href="../font/red.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
rr {
color: #F00;
}
body {
background-color: #818E98;
color: #FFF;
font-size: 9px;
}
.rrrr {
text-align: center;
}
.หหหห {
font-weight: bold;
color: #00F;
font-size: 14px;
}
-->
</style>
<link href="../font/น้ำเงิน.css" rel="stylesheet" type="text/css" />
<link href="../font/rr.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<body>
<form id="form1" name="form1" method="get" action="show_movie_search.php">
<table width="988" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3"><? include("menu2.php")?></td>
</tr>
<tr>
<td width="12" align="left" valign="top"><? include("menu1.php"); ?></td>
<td width="673" align="left" valign="top"><table width="694" border="0" align="left" cellspacing="0">
<tr>
<td height="155" colspan="3" align="center" valign="top" bgcolor="#999999"><div>
<table width="695" border="1" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<tr>
<td width="650" valign="top">
<table width="720" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="32" height="34" bgcolor="#666666"><div><img src="img/misc_i10.png" alt="" width="30" height="30" /></div></td>
<td width="512" bgcolor="#666666"><div class="สี้น้ำเงิน"> หนังใหม่ชนโรง</div></td>
<td width="136" align="right" bgcolor="#666666"><div class="สี้น้ำเงิน"><a href="show_movie.php">ดูทั้งหมด +++ </a></div></td>
</tr>
</table>
<div>
<?
$date90 = date('Y-m-d',strtotime("-60 day"));
$date0 = date('Y-m-d',strtotime("0 day"));
$strSQL = "SELECT * FROM movie WHERE mo_comming > '".$date90."' AND mo_comming <= '".$date0."' ";
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 3; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by mo_comming DESC LIMIT 3";
$objQuery = mysql_query($strSQL);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
echo "<td>";
$intRows++;
?>
</div>
<p><img src="img/movie/<?=$objResult["mo_pic"];?>" alt="" width="232" height="120" vspace="1" border="2" /></p>
<p><a href="show_movie_detail.php?id=<?=$objResult['mo_id']?>&name=<?=$objResult['mo_name'] ?>"><span class="สี้น้ำเงิน">
<?=$objResult["mo_name"];?>
...
<?
echo"</td>";
if(($intRows)%3==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
</span></a></p>
</td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td height="24" colspan="3" align="right"> </td>
</tr>
<tr>
<td width="33" height="24" bgcolor="#666666"><div><img src="img/misc_i10.png" alt="" width="30" height="30" /></div></td>
<td width="390" bgcolor="#666666"><div class="สี้น้ำเงิน"> โปรแกรมหน้า</div></td>
<td width="265" align="right" bgcolor="#666666"><div class="สี้น้ำเงิน"><a href="show_movie.php">ดูทั้งหมด +++ </a></div></td>
</tr>
<tr>
<td height="153" colspan="3" align="center" valign="top" bgcolor="#999999"><div>
<?
$date0 = date('Y-m-d',strtotime("0 day"));
$strSQL1 = "SELECT * FROM movie WHERE mo_comming > '".$date0."'";
$objQuery1 = mysql_query($strSQL1);
$Num_Rows1 = mysql_num_rows($objQuery1);
$Per_Page1 = 3; // Per Page
$Page1 = $_GET["Page"];
if(!$_GET["Page"])
{
$Page1=1;
}
$Prev_Page1 = $Page1-1;
$Next_Page1 = $Page1+1;
$Page_Start1 = (($Per_Page1*$Page1)-$Per_Page1);
if($Num_Rows1<=$Per_Page1)
{
$Num_Pages1 =1;
}
else if(($Num_Rows1 % $Per_Page1)==0)
{
$Num_Pages1 =($Num_Rows1/$Per_Page1) ;
}
else
{
$Num_Pages1 =($Num_Rows1/$Per_Page1)+1;
$Num_Pages1 = (int)$Num_Pages1;
}
$strSQL1 .=" order by mo_comming DESC LIMIT 3";
$objQuery1 = mysql_query($strSQL1);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows1 = 0;
while($objResult1 = mysql_fetch_array($objQuery1))
{
echo "<td>";
$intRows1++;
?>
</div>
<div><img src="img/movie/<?=$objResult1["mo_pic"];?>" alt="" width="196" height="109" border="2" /><br />
<span class="สี้น้ำเงิน"><a href="show_movie_detail.php?id=<?=$objResult1['mo_id']?>&name=<?=$objResult1['mo_name'] ?>">
<?=$objResult1["mo_name"];?>
...
<?
echo"</td>";
if(($intRows1)%3==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
</div></td>
</tr>
<tr>
<td height="24" colspan="3"> </td>
</tr>
<tr>
<td height="24" bgcolor="#666666"><div><img src="img/misc_i10.png" alt="" width="30" height="30" /></div></td>
<td bgcolor="#666666"><div class="สี้น้ำเงิน"> หนังเก่า</div></td>
<td align="right" bgcolor="#666666"><div class="สี้น้ำเงิน"><a href="show_movie.php">ดูทั้งหมด +++ </a></div></td>
</tr>
<tr>
<td height="117" colspan="3" align="center" bgcolor="#999999"><div>
<?
$date60 = date('Y-m-d',strtotime("-60 day"));
$strSQL12 = "SELECT * FROM movie WHERE mo_comming < '".$date60."'";
$objQuery12 = mysql_query($strSQL12);
$Num_Rows12 = mysql_num_rows($objQuery12);
$Per_Page12 = 6; // Per Page
$Page12 = $_GET["Page"];
if(!$_GET["Page"])
{
$Page12=1;
}
$Prev_Page12 = $Page12-1;
$Next_Page12 = $Page12+1;
$Page_Start12 = (($Per_Page12*$Page12)-$Per_Page12);
if($Num_Rows12<=$Per_Page12)
{
$Num_Pages12 =1;
}
else if(($Num_Rows12 % $Per_Page12)==0)
{
$Num_Pages12 =($Num_Rows12/$Per_Page12) ;
}
else
{
$Num_Pages12 =($Num_Rows12/$Per_Page12)+1;
$Num_Pages12 = (int)$Num_Pages12;
}
$strSQL12 .=" order by mo_comming DESC LIMIT $Page_Start12 , $Per_Page12";
$objQuery12 = mysql_query($strSQL12);
echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>";
$intRows12 = 0;
while($objResult12 = mysql_fetch_array($objQuery12))
{
echo "<td>";
$intRows12++;
?>
</div>
<div><img src="img/movie/<?=$objResult12["mo_pic"];?>" alt="" width="196" height="109" border="2" /><br />
<span class="สี้น้ำเงิน"><a href="show_movie_detail.php?id=<?=$objResult12['mo_id']?>&name=<?=$objResult12['mo_name'] ?>">
<?=$objResult12["mo_name"];?>
...
<?
echo"</td>";
if(($intRows12)%3==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
</div></td>
</tr>
<tr>
<td height="24"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="24"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="14"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
</table></td>
<td width="154" align="left" valign="top">
<table width="156" border="1" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="150" height="29" align="center" bgcolor="#666666" class="สี้น้ำเงิน">ค้นหาหนัง </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><label>
<br />
<select name="mo" id="mo" onChange = "Listmovie(this.value)" style="width:120px" >
<option>เลือกโซนหนัง</option><?
$strSQL = "SELECT * FROM movie_nation ORDER BY mn_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["mn_id"];?>"><?=$objResult["mn_name"];?></option>
<?
}
?>
</select>
<br />
<br />
<select id="movie" name="movie" style="width:120px" >
<option selected="selected">เลือกชื่อหนัง</option>
</select>
<? $_SESSION['mo_id ']=movie;?>
<br />
<br />
<input type="submit" name="button" id="button" value="ค้นหา" />
<br />
</label></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2012-03-07 22:51:42 |
By :
sibsan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
................................................................
|
ประวัติการแก้ไข 2012-03-09 13:19:45
|
|
|
|
Date :
2012-03-08 17:50:15 |
By :
sibsan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีใครตอบเลยหรอ เศร้าจัง
|
|
|
|
|
Date :
2012-03-09 13:20:41 |
By :
sibsan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|