j3rmain3 Posted October 2, 2006 Share Posted October 2, 2006 I had a earlier post about how i am creating dynamic charts using Libchart, PHP & MySQL. But i have another problemThe coding will not retrieve the data from the database. I dont know what i am missing because i am used to displaying information using $player = $_POST['player']; but im not using a HTML form. I just want the data from the database to appear straight onto the graphs.Here is the coding.....[code]<?phpinclude "libchart/libchart/libchart.php";$host = "localhost";$user = "root";$pass = "mysql";$db = "goals";$connection = mysql_connect($host,$user,$pass) or die ("Unable To Connect To Server"); #connect to servermysql_select_db($db) or die ("Unable To Get Database"); #connect to database$query = "SELECT * FROM goals_data";#set up the query$result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error());#run the query$numplayers = mysql_num_rows($result);#START CREATING THE CHART$chart = new VerticalChart(500, 500);for ($i=0; $i<=($numplayers-1);$i++) {##echo "This is $l_name, and he has scored $goals goal(s)<p>";$chart ->addPoint(new Point("$l_name","$goals"));}$chart ->setTitle("Goals Per Game");$chart ->render("graphs/playerReport.png");?>[/code]Help !?!ThanksJ3rmain3 Quote Link to comment Share on other sites More sharing options...
thedarkwinter Posted October 2, 2006 Share Posted October 2, 2006 Hiperhaps instead of for ($i=0; $i<=($numplayers-1);$i++) {##echo "This is $l_name, and he has scored $goals goal(s)<p>";$chart ->addPoint(new Point("$l_name","$goals"));}trywhile ($row = mysql_fetch_row($result)){ $l_name = $row[0]; // or whatever the index of name and goals is $goals = $row[1]; // also, perheps use "SELECT l_name,goals FROM goals_data" instead of *##echo "This is $l_name, and he has scored $goals goal(s)<p>";$chart ->addPoint(new Point("$l_name","$goals"));}I've never use the chart before so i cant help on that part... but the mysql may be useful...good luck Quote Link to comment Share on other sites More sharing options...
j3rmain3 Posted October 2, 2006 Author Share Posted October 2, 2006 You're a flipping genius. It works.thanksJ3rmain3 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.