<?
include ('conn.php');
//参数传递
if ($_GET[code]){
$_POST[bncode] = $_GET[code];
}$csql = $_POST[bncode];
if($csql) {
$asql = "select * from sdb_goods where bn = '".$csql."'";
$bsql = mysql_query($asql,$conn);    while($rows=mysql_fetch_array($bsql)){

//读取商品图片路径
$pic=$rows[small_pic];
$pic=explode("|",$pic);
$apic=$pic[0];
//
//读取品牌空间对应商家的LOGO
$brand = "select * FROM gq_shopitems where subject='$rows[syjdtname]'";
$abrand = mysql_query($brand);
$cbrand=mysql_fetch_array($abrand);
//
?>
<!--页面布局开始-->
HTML页面
<!--页面布局结束-->
<?
}// while结束
}//if 结束
 else{
 ?>
<!--页面布局开始-->
HTML页面
<!--页面布局结束-->
 <?
 }
?>大家帮忙看看,我该如何写这样一个判断:
如果提交的编号,经MYSQL查询后,返回空值,则在页面弹出错误。如何实现这样的效果呢?

解决方案 »

  1.   

    empty($rows)
    这个应该放在哪里?我尝试了很多次,结果页面显示空白了。
      

  2.   

    http://www.w3school.com.cn/php/php_mysql_select.asp  
      

  3.   

    我在上面加了一段$dsql = mysql_fetch_row($bsql);
    if(empty($dsql)){
    echo "您输入的货号有误";
    }
    能显示这段信息,如何使这段信息,能像弹窗一样,弹出来呢?
      

  4.   


    <?
    include ('conn.php');
    //参数传递
    if ($_GET[code]){
    $_POST[bncode] = $_GET[code];
    }$csql = $_POST[bncode];
    if($csql) {
    $asql = "select * from sdb_goods where bn = '".$csql."'";
    $bsql = mysql_query($asql,$conn);
    $dsql = mysql_fetch_array($bsql);
    if(empty($dsql)){
    echo "您输入的货号有误";
    }
        while($rows=$dsql){现在是这么写的,如果查询的值是对的,就会很慢。虚拟机都卡的不行了。
      

  5.   

    PHP有一个函数mysql_num_rows
      

  6.   

    了解,计数函数也能用上。那请问
    $esql=mysql_num_rows($bsql);
    当$esql < 1的时候 弹出对话框呢?
    而不是在页面中以普通文字的形式显示错误文字呢?
      

  7.   

    echo '<script>alert("提示")<script>';
      

  8.   

    我记得原生查询出来的数据是array({
      0=>""
    }) 
      

  9.   

    if(count($rows) ==null)
    echo 'error';