无法获得if语句的工作 [英] Can't get if statement to work

查看:76
本文介绍了无法获得if语句的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果查询根据条件没有返回任何内容,则说 - 成为第一个评论此配方的人!


如果查询确实返回了基于标准,然后显示结果。听起来很简单,但我不认为是否能够让其中一个工作。


[PHP]< strong>评论:< / strong>< ; br>< br>


< table width =" 95%" CELLPADDING = QUOT; 0" CELLSPACING = QUOT; 0" border =" 0">


<?php

include(''includes / dbcomment.php''); //有数据库连接的东西

$ result = mysql_query(" SELECT * FROM commenttable WHERE page_title =''$ title''AND allow =''yes''");

if(!$ result)

{

echo"成为第一个对此食谱发表评论的人!';

}

其他

{

while($ row = mysql_fetch_array($ result,MYSQL_ASSOC))

{

$ commentname = stripslashes($ row [''commentname'']);

$ commentpost = nl2br(stripslashes($ row [''commentpost'']));

$ commentpost = str_replace("< br />","< br>",$ commentpost);


echo ''

< tr>

< td>

< blockquote>

<! - -Name:< br> - >

''。 $ commentpost。 ''< br>

<! - 评论:< br> - >

~''。 $ commentname。 ''

< / blockquote>

< / td>< / tr>

< tr>< td>& ;&n ;;< / td>< / tr>

'';

}

}

echo"< / table>"; [/ PHP]

解决方案

result = mysql_query(" SELECT * FROM commenttable WHERE page_title =''

title''AND allow =''yes''");

if(!


result)

{

echo"成为第一个对此食谱发表评论的人!';

}

else

{

while(


If the query returns nothing based on the criteria, then say - "Be the first to comment on this recipe!"

If the query does return something based on the criteria, then show the results. Sounds simple enough, but I don''t think if ever been able to get one of these to work.

[PHP]<strong>Comments:</strong><br><br>

<table width="95%" cellpadding="0" cellspacing="0" border="0">

<?php
include(''includes/dbcomment.php''); //has database connect stuff
$result = mysql_query("SELECT * FROM commenttable WHERE page_title = ''$title'' AND allow = ''yes''");
if (!$result)
{
echo "Be the first to comment on this recipe!";
}
else
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$commentname = stripslashes($row[''commentname'']);
$commentpost = nl2br(stripslashes($row[''commentpost'']));
$commentpost = str_replace("<br />","<br>",$commentpost);

echo ''
<tr>
<td>
<blockquote>
<!--Name:<br>-->
'' . $commentpost . ''<br>
<!--Comment:<br>-->
~ '' . $commentname . ''
</blockquote>
</td></tr>
<tr><td>&nbsp;</td></tr>
'';
}
}
echo "</table>";[/PHP]

解决方案

result = mysql_query("SELECT * FROM commenttable WHERE page_title = ''


title'' AND allow = ''yes''");
if (!


result)
{
echo "Be the first to comment on this recipe!";
}
else
{
while (


这篇关于无法获得if语句的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆