从数据库中获取值并显示值,但我想显示值并显示空消息,这意味着如果 while 循环中没有值,则打印消息。
这是我的代码,请有人帮助我吗?
/* database link */
require_once '../db.php';
$query = "SELECT id,first_name FROM ajax_user";
$result = mysql_query($query,$connection) or die('Could connect !');
/* loop */
while ($row = mysql_fetch_array($result)) {
if($row['first_name']):
echo $row['first_name']; /* no problem print those values */
else:
/* here is the problem, message doesn't print if (ajax_user) */
/* table is empty */
echo 'no value your database !!';
endif;
}