我有跟随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'的行?实时将是0/1 (VARCHART)。
任何建议都非常感谢。
答案 0 :(得分:5)
只需将其添加到您的查询中:
$readNews_SQLslect .= " WHERE live = '0'";
答案 1 :(得分:3)
改变$readNews_SQLselect
$readNews_SQLselect = "SELECT ";
$readNews_SQLselect .= "id, content "; // rows names
$readNews_SQLselect .= "FROM ";
$readNews_SQLselect .= "news "; // table name
$readNews_SQLselect .= "WHERE live='0'"; // condition
答案 2 :(得分:1)
改变你的sql:
$readNews_SQLselect = "SELECT ";
$readNews_SQLselect .= "id, content "; // rows names
$readNews_SQLselect .= "FROM ";
$readNews_SQLselect .= "news "; // table name
$readNews_SQLselect .= "where live = '0' ";
如果条件:
if ($row['live'] == '0') {
echo '<li>' . $ID .' ' . $CONTENT . '</li>';
}