开发者

Condition to see if there are results for MySQL query?

I want to make a condition that returns true if there are results. How do I do it?

$result = mysql_query("SELECT * FROM `Groups` WHERE `City` = '$city2' LIMIT 12 OFFSET 6");


if (the condition) {

while($row = mysql_fetch_array( $result )) { ?>
    <a href="/?ciudad=<?php echo $city; ?开发者_如何学Python>&colegio=<?php echo $row['Group']; ?>" class="<?php if ($group == $row['Group']) { echo "selected"; } ?>"><?php echo $row['Group']; ?></a>  <?
    }   
}

Thanks


if (mysql_num_rows($result) > 0)


There should have something like:

if ($result.size > 0) {
  // do this
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜