如何遍历更新没有连续字段的表?
一个mysql表, 有下列字段
id,cs,
id虽为主键,但值并不连续
1,3,7,8,9,10,.....这种
我需要遍历update这个表,代码写出来了,下面的query不知道该怎么循环了
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> 这里我已得出这个表的总行数 $sql = "select count(*) from".$db_table; $exec = mysql_fetch_array($con); $allgoods = $exec[0]; //总行数 $sql = "update `".$db_table."' set cs = '".rand($summin,$summax)."' ";//更新语句
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> for ($i=0;$i
$sql = "select id from ".$db_table; $result = mysql_query($sql,$con); while($row=mysql_fetch_object($result)){ $id=$row->id; echo $id."<br>"; } <div class="clear"> </div>