Forum Moderators: coopster
I have stupid table like this one:
ID ¦ PERCENTAGE
1¦20%
2¦50%
3¦30%
4¦15%
Now, the stupid query, get the pecentage for an ID between 2 and 4.
Could you show me how to get the following array as an output:
$stupid_array = array('50%', '30%','15%');
So that I can simply remove duplicate and do an action for each element of the array (create horizontal bars in CSS for my graph).
Thank you
/* Create empty array */
$fArray = array();$p= "select id,percentage from table where id between '2' AND '5'";
$res=mysql_query($p) or die ("Fail pde");
while ($pres=mysql_fetch_array($res)) {
$id=$pres["id"]; $percentage=$pres["percentage"];
/* Add elements to array */
array_push($fArray, $pres["percentage"]); }
/* List each element */
while (list($key,$value) = each($fArray)) {
echo "$key : $value<br>";
}