Home >Backend Development >PHP Tutorial >怎么使用php批量处理mysql数据?希望高手能直接给出代码,多谢

怎么使用php批量处理mysql数据?希望高手能直接给出代码,多谢

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:49:391204browse

如何使用php批量处理mysql数据?希望高手能直接给出代码,谢谢!
比如数据库中有若干条数据,想将每一条数据中的二个字段相加得到的和插入到另一字段中:

cca   ccb    ccd    id
45      66     0     1
67      36     0     2
86      24     0     5
76      84     0     8
6      55      0     12
……

单条计算如下:

<?php<br />require_once("header.php");<br /><br />$q="select * from member where id='5'";<br />$r=$obj_db->simplequery($q);<br />$a=$obj_db->fetchRow($r,DB_FETCHMODE_ASSOC);<br /><br />$ccd=$a[cca]+$a[ccb];<br /><br />$obj_db->simplequery("update member set ccd='$ccd' where id='5'");<br />?>


有什么办法可以批量一次将每一条数据都计算完成?请给出详细代码,谢谢!
------解决方案--------------------
$obj_db->simplequery("update member set ccd=cca+ccb");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn