这是我的脚本,但我需要限制在mysql查询中我在LIMIT之前使用的mysql结果,但它没有用。
function display_menus($parent_id = 0){
$i=0;
$sql=mysql_query("SELECT * FROM customer_dog_details_db WHERE dog_id_parent = '$parent_id' && username='root' && dog_id_filter='$_GET[dog_id]'");
if(mysql_num_rows($sql) > 0){
echo "<ul class='tree'>";
while ($row = mysql_fetch_array($sql)){
echo "<li><a href=''><span style='font-size:14px;'>". $row['dog_name'] ."</span>";
echo "<br> ". $row['dog_id'] ." <br>";
echo "". $row['sex'] ."<br>";
echo "".$row['whelped_date']."<br>";
echo "</a>";
display_menus($row['dog_id']);
echo "</li>";
}
echo "</ul>";
}
}
display_menus();
答案 0 :(得分:1)
use:
$sql=mysql_query("SELECT * FROM customer_dog_details_db WHERE dog_id_parent = '$parent_id' AND username='root' AND dog_id_filter='$_GET[dog_id]' limit 0,1");
instead of:
$sql=mysql_query("SELECT * FROM customer_dog_details_db WHERE dog_id_parent = '$parent_id' && username='root' && dog_id_filter='$_GET[dog_id]'");