如何使用SQL数据在PHP中创建条形图? [关闭]

I am trying to create a simple bar graph to display results of an athletic event (e.g. 100m race) I have already generated a 'Results' table where the results of this event are displayed - but I want the user of the site to be able to click a 'view graph' type button which will show these results in a (horizontal) bar chart.

What's the easiest/simplest way?

The following is what I have already on my 'viewesults3.php' page:

            <?php
            session_start();
            require_once("connect.php");
            //require_once("restriction.php");
            ?>

                <html>
                    <body>
                        <div id="mainFrame">
                            <form id="results" method="get">
                                <table id="results" border="1" bordercolor="#FFCC66">
                                    <th bgcolor="#FFCC66">Result ID: </th>
                                    <th bgcolor="#FFCC66">Position: </th>
                                    <th bgcolor="#FFCC66">Time: </th>
                                    <th bgcolor="#FFCC66">Event ID: </th>       
                                    <th bgcolor="#FFCC66">Athlete ID: </th>

                                        <?php
                                            $result = mysql_query("SELECT * FROM Results");
                                            while ($row = mysql_fetch_array($result))
                                            {
                                                $rID = $row['rID'];
                                                $position = $row['position'];                                       
                                                $time = $row['time'];   
                                                $meID = $row['meID'];
                                                $atID = $row['atID'];               

                                                echo "<tr data-row='$rID'><td>$rID</td>";
                                                echo "<td>".$position."</td>";
                                                echo "<td>".$time."</td>";
                                                echo "<td>".$meID."</td>";
                                                echo "<td>".$atID."</td>";

                                                echo "</tr>";
                                            }
                                        ?>      
                                </table>
                            </form>
                        </div>          
                            <center>
                                    <div id="graphs" align="center">
                                    <a href=".php" class="button">Generate graph!</a>
                                    </div>
                            </center>
                    </body>
                </html>

One easy way using plain sql is mysql's REPEAT function. You can repeat a character X times for whatever the result value is (round or truncate to remove fractions).

Here is an example:

http://sqlfiddle.com/#!2/0e2d7/1/0

In that example I repeat the pipe character ( | ) x times depending on the "score" value (adjust as needed).

You can also highlight the the pipe characters in your HTML, making each a solid bar.