【发布时间】:2015-07-15 19:30:34
【问题描述】:
为什么人们不使用 for 、foreach 或 do..while() 以及为什么在 while 中省略增量计数器?
`<?php while ( $fa = mysql_fetch_array($sel1) )//uesd mysql_fetch_array() function in while loop
{
echo $fa['cid'];//display client id
}
// w3school 中的 Syntax give to 使用 this
$x = 1;
while($x <= 5) {
echo "The number is: $x";
$x++;
}
?>//show why we don't used mysql_fecth_array() like this
【问题讨论】:
-
如果可以的话,你应该stop using
mysql_*functions。它们不再被维护并且是officially deprecated。改为了解 prepared statements,并考虑使用 PDO,it's really not hard。
标签: php mysql loops while-loop