PHP while循环不起作用 [英] PHP while loop is not working

查看:173
本文介绍了PHP while循环不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <?php  
$ dbc = mysqli_connect(' localhost'' root'' '' sam_telephone');


$ query = SELECT * FROM master_name;
$ result = mysqli_query($ dbc,$ query);

$ display = mysqli_fetch_array($ result);

echo $ display [' f_name']; // /它显示结果很好

// 但是当我应用while循环时它不显示任何东西。

while( $ y = mysqli_fetch_array($ result)){
echo $ y [' f_name'];
}
// $ y ['f_name']应该给我一个结果,因为它显示我在线的结果
10 为什么 为什么在这条线上工作我不知道



?>

解决方案

dbc = mysqli_connect(' localhost'' root'' '' sam_telephone');


< blockquote> query = SELECT * FROM master_name;


result = mysqli_query(


<?php
$dbc=mysqli_connect('localhost','root','','sam_telephone');


$query="SELECT * FROM master_name";
$result=  mysqli_query($dbc,$query);

$display=mysqli_fetch_array($result);

echo $display['f_name']; /// its show me the result  which is fine 

// but when i apply while loop it does not show any thing.

while($y = mysqli_fetch_array($result)){
    echo $y['f_name'];
}
// $y['f_name'] should give me a result becuase it showing me the result on line
10 why its not working on this line i dont know 



?>

解决方案

dbc=mysqli_connect('localhost','root','','sam_telephone');


query="SELECT * FROM master_name";


result= mysqli_query(


这篇关于PHP while循环不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆