无法获得if语句的工作 [英] Can't get if statement to work
问题描述
如果查询根据条件没有返回任何内容,则说 - 成为第一个评论此配方的人!
如果查询确实返回了基于标准,然后显示结果。听起来很简单,但我不认为是否能够让其中一个工作。
[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> </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屋!