Jump to content

help me with displaying highscores in fash I got all part's exept one.


Recommended Posts

Let's say I have this tables:

highscoretable:

name | score

____________

me    | 123

she    | 321

him    | 456

 

 

numbers:

num |

_____

1    |

2    |

3    |

4    |

5    |

6    |

7    |

8    |

9    |

10    |

When I try this code:

 

<?

//here goes the login to database and choose one

$get_num = mysql_query("SELECT num FROM num ORDER BY num LIMIT 10");

$post = mysql_query("SELECT name,score FROM highscoretable ORDER BY score DESC LIMIT 10");

while ($highscoretable = mysql_fetch_array($post)) {

while ($numbers = mysql_fetch_array($get_num)) {

$num = $numbers['num'];

$name = $highscoretable['name'];

$score = $highscoretable['score'];

echo "&name".$num."=".$name."&score".$num."=".$score;

}

}

?>

 

 

it shows me this:

 

&name1=me&score1=123&name1=she&score1=321&name1=him&score1=456

 

it's suppose to show name1,name2,name3 etc.

 

and it shows only name1 why?

Soryy but i dont see the point for the & and $num information as there doing nothink are they?

 

am i going mad lol?

 

limit 10 for what there only 3 there

 

add anther field in the colum and each time there another name added add it to the new field.

 

<?php

$post = mysql_query("SELECT name,score FROM highscoretable ORDER BY score DESC");

while ($x = mysql_fetch_assoc($post)) {

$name = $x['name'];

$score = $x['score'];

   echo "name: $name score: $score";
}
   
?>

I want the output from the tables to be like this:

&name1=The_1st_players_name&score1=The_1st_players_score&name2=The_2nd_players_name&score2=The_2nd_players_score&name3=The_3rd_players_name&score3=The_3rd_players_score

<?php

$query = mysql_query("SELECT name, score FROM highscoretable ORDER BY score ASC");
$count = 1;

while(list($name, $score) = mysql_fetch_row($query)) {
$output .= "&name{$count}={$name}&score{$count}={$score}";
$count++;
}

echo substr($output, 1);

?>

 

Try that.

 

 

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.