[英]PHP - No Records Found
I am very, very new at PHP and I am trying to fix a code that someone else wrote. 我在PHP方面非常非常新,并且正在尝试修复其他人编写的代码。 I managed to do a couple of fixes and now the search is working, but I just can't get the "No Records Found" message.
我设法进行了一些修复,现在搜索可以正常进行,但是我无法收到“未找到记录”消息。
I am a novice trying to teach myself, so any feedback is appreciated. 我是一个新手,试图自学,因此希望您提供任何反馈意见。 Thank you in advance.
先感谢您。
Here is my code: 这是我的代码:
Blockquote
块引用
<?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>
Blockquote
块引用
You just want to show that message? 您只想显示该消息? Put this before or after the while loop:
将其放在while循环之前或之后:
<?php
if (mysql_num_rows($rs_main) == 0) {
echo "No records found.";
}
?>
After your query, count the results: 查询后,计算结果:
if(mysql_num_rows($rs_main)>0)
{
//put your code above here
}
else
{
echo 'No records found!';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.