PHP - while 循环更改
我有以下 while 循环。
$readNews_SQLselect = "SELECT ";
$readNews_SQLselect .= "id, content "; // rows names
$readNews_SQLselect .= "FROM ";
$readNews_SQLselect .= "news "; // table name
$readNews_SQLselect_Query = mysql_query($readNews_SQLselect);
//$indx = 1;
while ($row = mysql_fetch_array($readNews_SQLselect_Query, MYSQL_ASSOC)) {
$ID = $row['id'];
$CONTENT = $row['content'];
echo '<li>' . $ID .' ' . $CONTENT . '</li>';
//$indx++;
}
mysql_free_result($readNews_SQLselect_Query);
如果我添加 '$LIVE = $row['live'];'
,条件是仅包含 live
值字符串为“0”的行,它会是什么样子应该显示吗? Live 将是 0 / 1 (VARCHART)。
任何建议都非常感激。
I have following while loop.
$readNews_SQLselect = "SELECT ";
$readNews_SQLselect .= "id, content "; // rows names
$readNews_SQLselect .= "FROM ";
$readNews_SQLselect .= "news "; // table name
$readNews_SQLselect_Query = mysql_query($readNews_SQLselect);
//$indx = 1;
while ($row = mysql_fetch_array($readNews_SQLselect_Query, MYSQL_ASSOC)) {
$ID = $row['id'];
$CONTENT = $row['content'];
echo '<li>' . $ID .' ' . $CONTENT . '</li>';
//$indx++;
}
mysql_free_result($readNews_SQLselect_Query);
How would it look if I added '$LIVE = $row['live'];'
with condition that only rows with live
value string of '0' should be displayed? Live will be either 0 / 1 (VARCHART).
Any suggestion much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将其添加到您的查询中:
Just add this to your query:
改变
$readNews_SQLselect
Alter
$readNews_SQLselect
改变你的sql:
if条件:
if ($row['live'] == '0') {
回显'
' 。 $ID。' '。 $内容。 '
';
}
alter your sql:
if condition:
if ($row['live'] == '0') {
echo '<li>' . $ID .' ' . $CONTENT . '</li>';
}