更新记录 [英] Updating records

查看:78
本文介绍了更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢,它有效。另一个问题:

嗨伙计们,这段代码中的错误在哪里?更新日期字段时,它将使用相同的值更新表中的所有记录(例如,2008-01-07),而不是在每条记录中将日期增加一个。

$ schedule = position_courses ($ time_of_day);

$ x = 0;

$ z = 0;

$ temp = 0;

//获取初始日期

$ date = set_date(7,1,2008,true);


foreach($ schedule as $ value)

{

$ z ++;

if($ temp!= $ value [''day''])

{

$ temp = $ value [''day''];

++ $ x;


if ($ x == 5)

{

$ x = 0; //将计数器重置为0

}

}

$ day = $ date [''day''];

$ month = $ date [''month''];

$ year = $ date [''year''];

$ day_name = $ date [''day_name''];

$ full_date = $ year。'' - '。$ month。'' - ''。$ day;

if ($ z!= 1)$ date = set_date($ date [''day''],$ date [''month''],$ date [''year''],false);


//更新表格中的日期字段

$ sql =" UPDATE roomschedule SET date =''$ full_date''" ;;

if(!mysql_query($ sql,$ con))

{

die(''错误:''。mysql_error());

}

任何帮助都将深表感谢。 alexph@live.com

Thanks, it worked. Another problem:
Hey folks, where is the bug in this code? When updating the date field, it is updating all the records in the table with the same value (e.g. 2008-01-07) instead of incrementing the day by one in each record.
$schedule=position_courses($time_of_day);
$x=0;
$z=0;
$temp=0;
//getting the initial date
$date=set_date(7,1,2008,true);

foreach($schedule as $value)
{
$z++;
if($temp!=$value[''day''])
{
$temp=$value[''day''];
++$x;

if($x==5)
{
$x=0; //reseting the counter to 0
}
}
$day=$date[''day''];
$month=$date[''month''];
$year=$date[''year''];
$day_name=$date[''day_name''];
$full_date=$year.''-''.$month.''-''.$day;
if ($z!=1) $date=set_date($date[''day''],$date[''month''], $date[''year''],false);

// Updating the date field in the table
$sql="UPDATE roomschedule SET date=''$full_date''";

if (!mysql_query($sql,$con))
{
die(''Error: '' . mysql_error());
}
Any help will be deeply appreciated. alexph@live.com

推荐答案

schedule = position_courses(
schedule=position_courses(


time_of_day);
time_of_day);


x = 0;
x=0;


这篇关于更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆