 |
|
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 :
936 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |