PHP/SQL ORDER BY Problems =S |
![]() ![]() |
PHP/SQL ORDER BY Problems =S |
Dec 29 2007, 09:20 PM
Post
#1
|
|
|
Member ![]() ![]() Posts: 51 OS: XP |
I want the results to be a kind of Ranking board and the person with the most honor points is first and so on. Buuttt, me being a php/sql nub has its let downs Problem part of the script so far: CODE $result = mysql_query("SELECT * FROM characters ORDER BY name LIMIT 0, 50"); echo "<table border='1'> <tr> <th>Name</th> <th>Login</th> <th>Security Level</th> <th>Banned</th> <th>Last Login</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>honorPoints</th> <th>5</th> </tr>"; while($row = mysql_fetch_array($result)) /* <--- Line 32 */ { echo "<tr>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['race'] . "</td>"; echo "<td>" . $row['class'] . "</td>"; echo "<td>" . $row['gender'] . "</td>"; echo "<td>" . $row['level'] . "</td>"; echo "<td>" . $row['online'] . "</td>"; echo "<td>" . $row['playedtime'] . "</td>"; echo "<td>" . $row['publicNote'] . "</td>"; echo "<td>" . $row['guildid'] . "</td>"; echo "<td>" . $row['honorPoints'] . "</td>"; echo "<td>" . $row['killsLifeTime'] . "</td>"; echo "</tr>"; } echo "</table>"; I just want the top 50 players listed. Problems: When I run it, it has some problem with QUOTE Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home61c/sub007/sc38326-TTKC/www/honor.php on line 32 How can I make it so it displays a list of numbers at the start of the table descending from 1 > 50 IE Ranking the players. How can I make the First player bold, font size something like 32, second player bold, font size something like 27 and out line the top 3 players? I'm not really sure about editing appearance of the results individually as you can see Any help is much appreciated!! Thanks so much guys, -Linden |
|
|
Dec 30 2007, 02:02 PM
Post
#2
|
|
|
Spyware Veteran Posts: 20,727 From: Netherlands OS: XP Pro & Vista Ultimate |
First things first. The error you get usually means that you misspelled something in the query.
Try the command below. The error should give you some more useful information. CODE mysql_query ("SELECT * FROM characters ORDER BY name LIMIT 0, 50"') or die ('Error: '.mysql_error ()); To number the lines and highlight the first few, you can add a counter that gets increased every time the loop runs. I'll probably get shot if I suggest using a for ($i = 1; $<=50;$i++) loop, but you know exactly how many you want to display and you can simply add a line like this one CODE echo "<td>" . $i . "</td>"; to get the lines numbered. Next you can add conditional statements like CODE if ($i==1) { <STYLE="font-size: 32px; font-weight: bold;"> } after the <tr> tag to highlight the first few. |
|
|
Dec 31 2007, 12:59 AM
Post
#3
|
|
|
Member ![]() ![]() Posts: 51 OS: XP |
Thanks heaps
Now everything is how I want, I just need a little more help I want to arrange the info by adding 3 tables together. I've tried: $honor1 = $row['honorPoints']+$row['honorToday']+$row['honorYesterday']; $result = mysql_query("SELECT * FROM `characters` ORDER BY '$honor1' DESC LIMIT 3,47"); but it didn't work Thanks --Linden |
|
|
Dec 31 2007, 02:43 AM
Post
#4
|
|
|
Spyware Veteran Posts: 20,727 From: Netherlands OS: XP Pro & Vista Ultimate |
I'm not that experienced with MySQL, but I don't think that you can do that.
I'm afraid you'll have to query before you can start adding. But maybe someone else knows better. |
|
|
Jan 1 2008, 07:00 PM
Post
#5
|
|
|
Member ![]() ![]() Posts: 51 OS: XP |
Thanks heaps
Any one else? that can help? |
|
|
Jan 3 2008, 02:19 PM
Post
#6
|
|
|
Spyware Veteran Posts: 20,727 From: Netherlands OS: XP Pro & Vista Ultimate |
For lack of attention continued here:
http://www.geekstogo.com/forum/PHP-SQL-Ord...ms-t182007.html Closing this one. |
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies / Views | Topic Information | |||||
|---|---|---|---|---|---|---|---|
![]() |
1 / 491 | 4th January 2008 - 05:33 AM Linden started - last by gunner12 |
|||||
![]() |
2 / 408 | 1st July 2008 - 02:24 PM gregsmart79 started - last by gregsmart79 |
|||||
![]() |
2 / 856 | 14th July 2008 - 10:25 PM Jack Wetson started - last by Ax238 |
|||||
![]() |
4 / 144 | 29th October 2008 - 04:56 PM sheegirl started - last by sheegirl |
|||||
|
Time is now: 2nd December 2008 - 08:08 PM |
| Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk. |