Mr Chris Posted June 7, 2010 Share Posted June 7, 2010 Hi, I have a simple while loop where I call out two sets of rows $name and $value. Basically what I want to do is take however many come out of this query and dynamically stick them in the image below But i'll never know how many items will be called from that while loop, it could be five, or it could be 50. Anyone please help <?php $SQL = "Select * from table"; $RESULT = mysql_query ($SQL) OR die(mysql_error()); while($ROW=mysql_fetch_assoc($RESULT)) { $name = $ROW['name']; $value = $ROW['value']; } //Want to take all the values from name and value from the while loop and stick them in a google chart like so. But won't know how may there are ?? */ echo '<img border="0" src="http://chart.apis.google.com/chart?cht=p3&chco=17186B,348017,CC0000&chd=t:$,'.$value.','.$value.','.$value.'&chs=500x200&chl='.$name.'|'.$name.'|'.$name.'" />'; ?> Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 7, 2010 Share Posted June 7, 2010 <?php $SQL = "Select * from table"; $RESULT = mysql_query ($SQL) OR die(mysql_error()); $names = array(); $valuess = array(); while($ROW=mysql_fetch_assoc($RESULT)) { $names[] = $ROW['name']; $values[] = $ROW['value']; } $nameStr = implode('|', $names); $valueStr = implode(',', $values); //Want to take all the values from name and value from the while loop and stick them in a google chart like so. But won't know how may there are ?? */ echo '<img border="0" src="http://chart.apis.google.com/chart?cht=p3&chco=17186B,348017,CC0000&chd=t:$,'.$valueStr.'&chs=500x200&chl='.$nameStr.'" />'; ?> Quote Link to comment Share on other sites More sharing options...
Mr Chris Posted June 7, 2010 Author Share Posted June 7, 2010 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.