Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?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 



?>
Posted

1 solution

try using this

PHP
while($y = mysqli_fetch_array($result,MYSQLI_ASSOC))
{
    echo $y['f_name'];
}
 
Share this answer
 
Comments
arifsuhail123 9-Nov-13 5:34am    
Thanks for reply, and yah i did tried it and it work fine, but please can you explain to me why my original code did not work

Thanks
Enemali William 9-Nov-13 5:55am    
You needed to tell the function how to fetch the array either as associative,numeric or both. Please mark as correct solution so as to help others. Thanks
arifsuhail123 9-Nov-13 6:07am    
thanks, i do understand now
Joezer BH 10-Nov-13 5:11am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900