Jump to content

Quiz table


tecmeister

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/91452-quiz-table/#findComment-468534
Share on other sites

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>';
?>

Link to comment
https://forums.phpfreaks.com/topic/91452-quiz-table/#findComment-468572
Share on other sites

$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!

Link to comment
https://forums.phpfreaks.com/topic/91452-quiz-table/#findComment-468839
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/91452-quiz-table/#findComment-468961
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.