Reputation: 23
my database sample is like this
database:test
table:test
id name password message active
1 test testpass testmsg no
2 test2 testtest testmsg2 no
and when i run sql query and show it in php it just gives one result. php part was,
$a=mysqli_query($con,"select name from test where active='no'");
$b=mysqli_fetch_array($a);
print_r($b);
and it showed only the first record
test
can anybody please suggest me,where I am doing wrong?
Upvotes: 0
Views: 68
Reputation: 4557
You have to fetch the result using loop :
$b = mysql_fetch_array($query)
foreach($b as $b)
{
echo $b[];
]
Upvotes: 0
Reputation: 14811
This is desired behavior of PHP. You should fetch the rows in loop, like this:
$result = mysqli_query($con,"select name from test where active='no'");
while ($row = mysqli_fetch_array($result))
{
print_r($row);
}
Upvotes: 2
Reputation: 31920
Use a while loop to iterate over all the records
$a=mysqli_query($con,"select name from test where active='no'");
while($b=mysqli_fetch_array($a))
print_r($b);
Upvotes: 2