tecmeister Posted February 16, 2008 Share Posted February 16, 2008 Hi everyone, How do i create a Table at the end of a quiz? I want it goes by the highest score. Thank for your help. tecmeister Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 17, 2008 Share Posted February 17, 2008 i am assuming you are storing peoples scores in a database then you could have a script like this <?php mysql_connect(); mysql_select_db('quiz'); $result=mysql_query('SELECT * FROM `quiz` ORDER BY `score`'); echo '<table>'; while($row=mysql_fetch_array($result)){ echo "<tr> <td>{$row['name']}</td> <td>{$row['score']}</td> </tr>"; } echo '</table>'; ?> Scott. Quote Link to comment Share on other sites More sharing options...
tecmeister Posted February 17, 2008 Author Share Posted February 17, 2008 I out in the code but im getting this error. Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nurevolution.co.'@'localhost' (using password: NO) in /home/sites/nurevolution.co.uk/public_html/quiz/adults easy/adults easy finsih.php on line 18 Could not connect:Access denied for user 'nurevolution.co.'@'localhost' (using password: NO) So i tried this: <?php $dbhost = "localhost"; $dbname = "*******"; $dbuser = "********"; $dbpass = "********"; mysql_connect ($dbusername,$dbscore)or die("Could not connect:".mysql_error()); mysql_select_db('adults easy'); $result=mysql_query('SELECT * FROM `adults easy` ORDER BY `score`'); echo '<table>'; while($row=mysql_fetch_array($result)){ echo "<tr> <td>{$row['username']}</td> <td>{$row['score']}</td> </tr>"; } echo '</table>'; ?> Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 17, 2008 Share Posted February 17, 2008 I am not sure where your mysql_connect vars are coming form but i would suggest it should look like this mysql_connect ($gbhost,$dbuser,$dbpass)or die("Could not connect:".mysql_error()); Scott. Quote Link to comment Share on other sites More sharing options...
tecmeister Posted February 17, 2008 Author Share Posted February 17, 2008 O yeah. Bloody hell. I have got to stop staying till 3 in the morning. Im a total newbie. Quote Link to comment Share on other sites More sharing options...
tecmeister Posted February 17, 2008 Author Share Posted February 17, 2008 I have entered the script that you told me to and there is nufin on the screen. Quote Link to comment Share on other sites More sharing options...
AndyB Posted February 17, 2008 Share Posted February 17, 2008 $dbhost = "localhost"; $dbname = "*******"; $dbuser = "********"; $dbpass = "********"; mysql_connect ($dbusername,$dbscore) or die("Could not connect:".mysql_error()); Take a careful look at your code. Is $dbusername defined? Is $dbscore defined? Neither is! Quote Link to comment Share on other sites More sharing options...
ratcateme Posted February 17, 2008 Share Posted February 17, 2008 are you sure you are selecting the DB i would recomend changing the select_db line to mysql_select_db($dbname) or die("Could not select database:".mysql_error()); also check the source to see it <table> and </table> are being outputted. Scott. 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.