如何使用mysql
在php中停止空组我想停止空行组
此代码显示如下
-----------------
<--- and this empty rows is showing empty group how to stop this
-----------------
UK
-----------------
UAE
-----------------
USA
-----------------
我想要这样
-----------------
UK
-----------------
UAE
-----------------
USA
-----------------
这是代码
<?php
mysql_connect('localhost', 'user', 'password.') or die (mysql_error());
mysql_select_db('phone') or die (mysql_error());
$result = mysql_query("SELECT * from topdata GROUP BY model");
//While there are rows to display
while($row = mysql_fetch_array($result)){
//Display the results from the current row and a line break
echo "<li><a href=../model/".urlencode($row['model']).".html>" .$row['model']."</a></li>";
}
?>
答案 0 :(得分:2)
<?php
mysql_connect('localhost', 'user', 'password.') or die (mysql_error());
mysql_select_db('phone') or die (mysql_error());
$result = mysql_query("SELECT * from topdata GROUP BY model");
//While there are rows to display
while($row = mysql_fetch_array($result))
{
//Display the results from the current row and a line break
if ( ! empty($row['model'])) // check if not empty
{
echo "<li><a href=../model/".urlencode($row['model']).".html>" .$row['model']."</a></li>";
}
}
?>