After querying my data from database I have this type of array in $rown
Array
(
[0] => 60
[id] => 60
[1] => 78
[cholest] => 78
[2] => 2014-07-13
[Cdate] => 2014-07-13
)
Array
(
[0] => 61
[id] => 61
[1] => 0
[cholest] => 0
[2] => 2014-07-15
[Cdate] => 2014-07-15
)
My code
$resultn = mysql_query($sqln);
if(mysql_affected_rows() > 0)
{
while($rown = mysql_fetch_array($resultn))
{
$result_finalb = $rown["id"];
}
}
when I print $result_finalb
then show only second array data, but I want to show both array data.
You are missing square brackets. Use this:
$resultn = mysql_query($sqln);
if(mysql_affected_rows() > 0)
{
while($rown = mysql_fetch_array($resultn))
{
$result_finalb[] = $rown["id"];
}
}
You are setting a single variable $result_finalb
with a value. If you want to create an array of values, using $result_finalb[]
will create an array item with the value you assign. The first time will be $result_finalb[0]
, second will be $result_finalb[1]
, and so on through however many iterations you go through.