|
|
|
update ข้อมูล ไม่ได้ ช่วยดู code ด้วยค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
$host="localhost";//�������
$user="root";//���ͼ����ҹ�ҹ������
$pass="";//���ʼ����ҹ�ҹ������
$db="4digits";//���Ͱҹ������
mysql_connect( $host,$user,$pass) or die ("�Դ��͡Ѻ�ҹ������ Mysql ����� ");
mysql_select_db($db) or die ("�������ö��Ҷ֧���ҧ��");
mysql_query("SET NAMES UTF8");
$sql = "select * from renew" ;
$db_query=mysql_db_query($db,$sql);
$a=0;
while ( $result = mysql_fetch_array($db_query) )
{
$enddate=$result[enddate];
$startdate=$result[startdate];
$id = $result[id];
$year =$result[year] ;
$strcount = "select count(*) as countid from renew WHERE id = '$id' " ;
$result1 = mysql_query($strcount);
$countid = mysql_result($result1,0,"countid");
while ($year <= $countid)
{
$strSQL = "UPDATE renew SET renew.year = '$year' where renew.startdate = '$startdate' and renew.id = '$id' " ;
mysql_db_query($db,$strSQL);
$ss = strtotime($startdate );
$startdate = mktime(0,0,0,date('m', $ss),date('d',$ss),date('y', $ss)+1);
$startdate = date( 'Y-m-d', $startdate );
echo $id;
echo " ";
echo $startdate;
echo $year;
echo $strSQL;
echo "<BR>";
$year++;
}
$a++;
}
mysql_close() ;
?>
Tag : PHP
|
|
|
|
|
|
Date :
2012-02-16 16:13:42 |
By :
garfieldgril |
View :
899 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error ว่าอะไรครับ
จะได้ดูให้ง่ายๆ
|
|
|
|
|
Date :
2012-02-16 16:18:03 |
By :
13eachz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
วนจนมึนเลยอ่ะ
อาจเป็นเพราะ วนจน ค่า $startdate เปลี่ยน เลยอัพเดทไม่ได้
|
|
|
|
|
Date :
2012-02-16 16:24:09 |
By :
randOmizE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo $strSQL."<br><br>";
mysql_db_query($db,$strSQL);
ลองดูค่า loop ของ SQL ครับ ว่า Loop ไหนผิด
|
|
|
|
|
Date :
2012-02-16 16:33:40 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|