时间:2021-07-01 10:21:17 帮助过:3人阅读
mysql_query('set names gbk',$conn); mysql_select_db('htc',$conn); $count = 'select count(*) from phone'; $query = mysql_query($count,$conn); //记录总数 $recordcount = mysql_result($query, 0,0); //每页多条 $pagesize = 5; //总页数 $pagecount = ceil($recordcount/$pagesize); //当前页 $currpage = 1; if($_GET){ $currpage = (int)$_GET['p']; } $currpage = $currpage<1 ? 1 : $currpage; $currpage = $currpage>$pagecount ? $pagecount : $currpage; $start = ($currpage-1)*$pagesize; $sql = "select * from phone order by id desc limit $start,$pagesize"; $result = mysql_query($sql,$conn); while($row=mysql_fetch_array($result)){ foreach ($row as $k=>$va){ //echo ''; //print_r($row); echo ""; echo ""https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/""; echo "'; } } echo '首页 '; echo '下页 '; echo '上页 '; echo "末页 "; echo "[{$currpage}/{$pagecount}][共{$recordcount}记录,每页{$pagesize}条]"; ?>$va[1]
$va[4],$va[5]
$va[6],$va[7]
$va[8],$va[9]
$va[10]
"; echo "售价:¥$va[3]
"; echo ""; //echo '
';
//print_r($row);
echo "";
echo ""https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/"";
echo "
$va[1]
$va[4],$va[5]
$va[6],$va[7]
//所以$va[6],$va[7]只能是单个字符,如果$val没有那么长,则就要报错了
我认为你的本意应该是
while($val=mysql_fetch_array($result)){
//foreach ($row as $k=>$va){
也就是说:$va[6],$va[7]是第6,7个字段的值
------解决方案--------------------
去掉foreach那层循环。
while($va = mysql_fetch_row($result) ){
// https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/
}
至于你#2说的问题,我不会正则表达式所以帮不上忙
------解决方案--------------------