Jump to content

Small Problem Again


divinedesigns1
 Share

Recommended Posts

so im reading this book, "head first" and im stuck onces again because im not too sure how to fix this problem, they said to give the index page where it displays the people high score to be at the top of all the rest of the scores so you would have something like this

<table><tr><td>Top Score: 5643541343984384</td></tr><tr><td>Name: </td><td>Smith Ugly</td></tr><tr><td>Score: </td><td>34345132151</td></tr><tr><td colspan="2" align="right">The Images displays here</td></tr></table>

but instead i end up having this http://www.divinedesigns1.com/demo/index.php which isnt correct because the "top score" is displayed at the top of every submittion this is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><?phprequire_once('skimg.php');require_once('my_connect.php');//connect to the database$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);//retrieve the score data form$query = "SELECT * FROM scorekeeper";$data = mysqli_query($conn, $query);//loop through the array of data, formatting it as HTMLecho '<table>'; //TABLE START HERE$i = 0;while($row = mysqli_fetch_array($data)){//Display the score dataif($i == 0){  echo '<tr><td colspan="2" class="topscore">Top Score' . $row['score'] . '</td></tr>'; }echo '<tr><td class="scoreinfo">';echo '<span class="score">' . $row['score'] . '</span><br/>';echo '<strong>Name: </strong>' . $row['name'] . '<br/>';echo '<strong>Date: </strong>' . $row['date'] . '</td>';if(is_file(SK_UPLOADPATH . $row['screenshot']) && filesize(SK_UPLOADPATH . $row['screenshot']) > 0){  echo '<td><img src="' . SK_UPLOADPATH . $row['screenshot'] . '" alt="Score image" /></td></tr>';}else {  echo '<td><img src="' . SK_UPLOADPATH. 'unverified.gif' . '" alt="Unverified Score" /></td></tr>';}$itt;}echo '</table>';mysqli_close($conn);?></body></html>

i double checked everything but maybe i am missing something, can you point me in the right direction?

Link to comment
Share on other sites

It looks like you're trying to avoid posting the top score by checking to see if the value of $i is 0 or not. Correct? If you want to take that route, you'll want to change...

$itt;

to

$i++;

Or you can grab the top score separately and leave it outside of your while() loop.

Link to comment
Share on other sites

It looks like you're trying to avoid posting the top score by checking to see if the value of $i is 0 or not. Correct? If you want to take that route, you'll want to change...
$itt;

to

$i++;

Or you can grab the top score separately and leave it outside of your while() loop.

ok alright, ill try that thank you. sorry for the late reply, didnt saw that someone replied until now
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...