查询数据库只读一条相关信息,代码那里出错了(PHP)求指点
mysql_query("SETNAMES'UTF8'");$sql="SELECT*FROM`goods`WHERE`goodsid`='$value'ORDERBYi...
mysql_query("SET NAMES 'UTF8'");
$sql = "SELECT * FROM `goods` WHERE `goodsid`='$value' ORDER BY id DESC LIMIT 0,$limit";
//$sql = "SELECT * FROM `goods` AS a WHERE 1 $value ORDER BY id DESC LIMIT 0, $limit";
//$sql= "select * from goods where goodsId = '$value'";
$result = mysql_query($sql);
$noR = false;
while($row = mysql_fetch_array($result))
{
$goodsId='款号:'.$row['goodsId'].'';
$goodsName=$row['goodsName'];
$rdr='码数:';
$L=$row['goodsCategoryName'];
$xl=$row['taobaoUserUrl'];
$result=<<<DATA
$goodsId\n$goodsName\n $rdr L:$L 件 XL:$xl 件\n
DATA;
if ( !$noR) $noR = true;
}
if ( !$noR ) {
$result= '没有搜索到相关数据'; //
}
mysql_free_result( $result );//释放内存
mysql_close($con);
//以下显示出相应内容
return $result; 展开
$sql = "SELECT * FROM `goods` WHERE `goodsid`='$value' ORDER BY id DESC LIMIT 0,$limit";
//$sql = "SELECT * FROM `goods` AS a WHERE 1 $value ORDER BY id DESC LIMIT 0, $limit";
//$sql= "select * from goods where goodsId = '$value'";
$result = mysql_query($sql);
$noR = false;
while($row = mysql_fetch_array($result))
{
$goodsId='款号:'.$row['goodsId'].'';
$goodsName=$row['goodsName'];
$rdr='码数:';
$L=$row['goodsCategoryName'];
$xl=$row['taobaoUserUrl'];
$result=<<<DATA
$goodsId\n$goodsName\n $rdr L:$L 件 XL:$xl 件\n
DATA;
if ( !$noR) $noR = true;
}
if ( !$noR ) {
$result= '没有搜索到相关数据'; //
}
mysql_free_result( $result );//释放内存
mysql_close($con);
//以下显示出相应内容
return $result; 展开
展开全部
$con = mysql_connect("127.0.0.1","administration","cunadmin");
mysql_select_db('kucun', $con);
mysql_query("SET NAMES 'UTF8'");
$sql = "SELECT * FROM `goods` WHERE `goodsid`=$value ORDER BY id DESC LIMIT 6";
$arr=array();
$query = mysql_query($sql);
$num=0;
while ( $rs =mysql_fetch_array($query) ) {
mysql_select_db('kucun', $con);
mysql_query("SET NAMES 'UTF8'");
$sql = "SELECT * FROM `goods` WHERE `goodsid`=$value ORDER BY id DESC LIMIT 6";
$arr=array();
$query = mysql_query($sql);
$num=0;
while ( $rs =mysql_fetch_array($query) ) {
2018-03-20
展开全部
你的$limit变量的值多少啊?你用了limit分页,limit传的几就查几条出来啊
追问
$limit=5
根据关键词查询,然后返回一个变量里。上面那个代码都是东拼西凑而成的。应是能查询出来几条信息出来的,但死活只显示第一条。不知是那里出错的,百度了一天,还找不到解决方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询