php数据库更新多条数据问题?
$name=array{'yuan','wang','li'};$price=array{'10','21','5'};怎么更新这三条数据?$sql="updatetab...
$name = array{'yuan','wang','li'};
$price = array{'10','21','5'};
怎么更新这三条数据?
$sql = "update tabel set price=$price where name = $name"; 展开
$price = array{'10','21','5'};
怎么更新这三条数据?
$sql = "update tabel set price=$price where name = $name"; 展开
2个回答
展开全部
<?php
$name = array('yuan','wang','li');
$price = array('10','21','5');
foreach($name as $key => $_name){
$_price = $price[$key];
$sql = "update tabel set price='".$_price."' where name = '".$_name."'";
//echo $sql, "\n";
//to do ...
}
2016-06-22
展开全部
foreach循环下数组不就可以了
追问
循环$name,那$price是不也得循环
追答
$data = array_combine($name, $price);
foreach($data as $key => $val)
{
$sql = "update tabel set price=$val where name = $key";
//...
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询