PHP code
How can I retrieve elements of an array in numeric format?
Look at this code:[code=php]
$query = "SELECT price FROM $tbl_name";
$result = mysql_query($qu ery)
or die(mysql_error ());
while($row = mysql_fetch_row ($result)) {
//$rowNum++;
$test[]=$row;
}[/code]
Let's say the column price has three elements: 33, 47 and 65.
Please pay attention since the elements of column price are numbers I have to retrieve them as numbers.
Outside the while loop I need to to have the elements of $test array as:[code=php]
$element1= 33;
$element2= 47;
$element3=65;[/code]
if I use gettype like;
echo gettype($elemen t1);
it should NOT SAY "string" that's a NO NO
They should be numbers.
Can anyone help me with this? Please read the question and the code carefully before you answer.
Thanks
How can I retrieve elements of an array in numeric format?
Look at this code:[code=php]
$query = "SELECT price FROM $tbl_name";
$result = mysql_query($qu ery)
or die(mysql_error ());
while($row = mysql_fetch_row ($result)) {
//$rowNum++;
$test[]=$row;
}[/code]
Let's say the column price has three elements: 33, 47 and 65.
Please pay attention since the elements of column price are numbers I have to retrieve them as numbers.
Outside the while loop I need to to have the elements of $test array as:[code=php]
$element1= 33;
$element2= 47;
$element3=65;[/code]
if I use gettype like;
echo gettype($elemen t1);
it should NOT SAY "string" that's a NO NO
They should be numbers.
Can anyone help me with this? Please read the question and the code carefully before you answer.
Thanks
Comment