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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.