1

I need to write a script that is able to search for a particular result, put it into a graph. I've already developed the graph. However, when hovered over the section of the graph, there would be a list of the data that is in that section.

Example:
25% of the pie chart is boys. When hovered over the boys, it will show a list of the names of the boys. In other words, i would need to be able to retrieve the multiple data from the database, put it in a list and echo out the results.


so far I've managed to code this:

$data = array();<br>
    while ($row = mysqli_fetch_array($result))<br>
    {<br>
    $data[]= $row;<br>
}<br>
echo "$data";

However I do not know what I'm echoing out. Please help me

5
  • $data= $row; for data assign data to an array . please can you provide the data structure of your chart and database Commented Nov 18, 2014 at 8:34
  • Uhm. on Hover you can call (with javascript) an ajax call that will ask a php page information about that. Commented Nov 18, 2014 at 8:35
  • I don't think it's a good idea to make a call to the database every time someone hovers over a pie chart. It's better if you get the results on page load and then show them using JS when someone hovers their mouse over the pie chart. Commented Nov 18, 2014 at 8:41
  • I'm sorry, I dont have enough reputation to be able to input an image. >< @AnikIslamAbhi gwt-google-apis.googlecode.com/svn/wiki/SimpleVizQuery-1.png Commented Nov 18, 2014 at 8:58
  • Something like that, however, when hovered, it would show the list of names retrieved from the database @AnikIslamAbhi Commented Nov 18, 2014 at 8:58

1 Answer 1

1

i guess this is what you want do to...

$data = array();
while ($row = mysqli_fetch_array($result)) {
    array_push($data, $row);
}
print_r($data); // dump
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much, but I just want 1 section of the data. I tried that code by using echo $data[0]['gene_id'] But it only showed 1 of the results. should i also put it in a loop?
maybe... array_push($data, $row['gene_id']); or just 'SELECT gene_id from ...' in your SQL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.