我在PHP方面非常非常新,并且正在尝试修复其他人编写的代码。我设法进行了一些修复,现在搜索可以正常进行,但是我无法收到“未找到记录”消息。

我是一个新手,试图自学,因此希望您提供任何反馈意见。先感谢您。

这是我的代码:


  块引用


<?php $counter = 0;
      while ($data_main = mysql_fetch_object($rs_main)) { ?>
          <div id="thumbnail_div">
            <a href="more_info.php?id=<?php echo $data_main->iuniqid; ?>"><*image here*/<?php echo $data_main->prefix; ?>_<?php echo stripslashes($data_main->iname); ?>" border="0" /></a><br />
            <?php if ($data_main->itype != '') {
                    $sql_type = " select itype from type where id = ". $data_main->itype;
                    $rs_type = mysql_query($sql_type);
                    $data_type = mysql_fetch_object($rs_type);  ?>
            <*image here*<?php echo $data_main->itype; ?>.*extension*" width="10" height="10" alt="<?php echo $data_type->itype; ?>" title="<?php echo $data_type->itype; ?>" />
            <?php } ?>
            <?php if ($data_main->iotype != '' ) {
                    $sql_otype = " select itype from original_type where id = ". $data_main->itype;
                    $rs_otype = mysql_query($sql_otype);
                    $data_otype = mysql_fetch_object($rs_otype); ?>
            <*image here*<?php echo $data_main->iotype; ?>.*extension*" width="10" height="10" alt="<?php echo $data_otype->itype; ?>" title="<?php echo $data_otype->itype; ?>" /><br />
            <?php } ?>
          <span class="textBody">Image ID <?php echo $data_main->iuniqid; ?></span>
         </div>
<?php   $counter++;
        if ($counter == 5) {
            $counter = 0; ?>
            <div id="separatordiv">   </div>
<?php   }
      } ?>
            <div style="clear:both;"></div>
            <div align="center"><?php echo $page->get_page_nav(); ?></div>



  块引用

最佳答案

您只想显示该消息?将其放在while循环之前或之后:

<?php
if (mysql_num_rows($rs_main) == 0) {
    echo "No records found.";
}
?>

09-11 19:24