帮忙看下这段Php代码哪里除了问题?为什么一运行firefox就会死机? 数据库里只有一行数据。

[复制链接]
查看11 | 回复1 | 2011-5-16 10:45:49 | 显示全部楼层 |阅读模式
?php
include(dirname(__FILE__).\"/includes/connexion.php\");
$res=mysql_query(\"SELECT*FROMprojetsorderbyid_projetdesc\")ordie(mysql_error());
$ligne=mysql_fetch_assoc($res);
if(mysql_num_rows($res)==0)
{
        echo\'Aucunprojetestdisponibleactuellement.\';
}
else
{
?
        table
        tr
        tdNom/td
        tddatecreation/td
        tdresume/td
        /tr

?php
while($ligne)
        {
?

                tr
                td?phpecho$ligne[\'nom\'];?/td
                td?phpecho$ligne[\'date_creation\'];?/td
                td?phpecho$ligne[\'resume\'];?/td
/tr

?php
}
?
        /table
?php
mysql_close();
}
?
回复

使用道具 举报

千问 | 2011-5-16 10:45:49 | 显示全部楼层
你把这句$ligne=mysql_fetch_assoc($res);放到while里面。

?php
include(dirname(__FILE__).\"/includes/connexion.php\");
$res=mysql_query(\"SELECT*FROMprojetsorderbyid_projetdesc\")ordie(mysql_error());
if(mysql_num_rows($res)==0)
{
        echo\'Aucunprojetestdisponibleactuellement.\';
}
else
{
?
        table
        tr
        tdNom/td
        tddatecreation/td
        tdresume/td
        /tr

?php
while($ligne=mysql_fetch_assoc($res))
        {
?

                tr
                td?phpecho$ligne[\'nom\'];?/td
                td?phpecho$ligne[\'date_creation\'];?/td
                td?phpecho$ligne[\'resume\'];?/td
/tr

?php
}
?
        /table
?php
mysql_close();
}
?


你那样的话$ligne是一个数组,while就一直循环下去,程序永远停不了了。或者取出来不用while,用foreach也可以。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行