<?
$DBAlanadi = "SELECT * FROM Alanadi";
$ACAlanadi = mysql_query($DBAlanadi);
$TotalAlanadi = mysql_num_rows($ACAlanadi);
$Alanadi = mysql_fetch_object($ACAlanadi);
if($TotalAlanadi!=0):
while( $Fiyat=$Alanadi ):
echo '<a>'.$Fiyat->fiyat.'</a>';
endwhile;
endif;
mysqli_free_result($Alanadi); ?>
第1行只是无休止地转动
但
我想要 40 TL 35 TL 50 TL
答案 0 :(得分:0)
每次循环都需要调用mysql_fetch_object()
。否则你只是一遍又一遍地处理第一行。
<?
$DBAlanadi = "SELECT * FROM Alanadi";
$ACAlanadi = mysql_query($DBAlanadi);
$TotalAlanadi = mysql_num_rows($ACAlanadi);
if($TotalAlanadi!=0):
while( $Fiyat= mysql_fetch_object($ACAlanadi) ):
echo '<a>'.$Fiyat->fiyat.'</a>';
endwhile;
endif;
mysql_free_result($Alanadi);
?>
BTW,mysql
扩展已被弃用多年,并且已从当前版本的PHP中完全删除。您应该尽快转换为mysqli
或PDO
。
如果结果来自mysqli_free_result
,则无法致电mysql
,您必须使用mysql_free_result
。