Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySql:更新多个列_Php_Mysql - Fatal编程技术网

Php MySql:更新多个列

Php MySql:更新多个列,php,mysql,Php,Mysql,我的时间表如下所示: id period mon mon_tch tue tue_tch wed wed_tch -- ------ --- ------- --- ------- --- ------- 1 prd1 4 5 8 7 6 3 2 prd2 6 3 4 5 8

我的时间表如下所示:

  id  period   mon   mon_tch   tue   tue_tch   wed   wed_tch
  --  ------   ---   -------   ---   -------   ---   -------
   1   prd1     4       5       8        7      6       3    
   2   prd2     6       3       4        5      8       7
我的老师科目表:

   id   tchr   subject
   --   ----   -------
    1     5       4
    2     7       8  
其中
mon
中的值是主题id,
mon\u tch
teacher\u id
,依此类推

当管理员通过表单更改“教师科目”表中教师的科目时(例如:id为5的教师科目从8更改为9),我想用分配的新科目更新我的时间表表


认为教师主题表中的主题字段将以某种方式更新

标准化设计可能如下所示

period day subject teacher 
--------------------------
 1     mon   4       5       
 1     tue   8       7  
 1     wed   6       3    
 2     mon   6       3       
 2     tue   4       5      
 2     wed   8       7

。。。其中(期间,日)构成复合PK。也就是说,这里可能还有一些冗余。

我不太明白你到底在干什么。也许是加入的更新@巴茨:不,我不想加入任何一张桌子。。只需在一个更新查询中替换多个列值。例如“更新表\u名称集field1=new-value1,field2=new-value2,其中id=1”?使用级联功能。。。这将对你有更多的帮助。你能给我们一些演示代码吗,这样我们就知道你到底想要什么了