Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Spyware, virus, trojan, fake security or privacy alerts? Read the malware cleaning guide. Want to reply to a topic, start a new one, or remove the advertising? Join today (always free).
      
 
Closed TopicStart new topic
PHP/SQL ORDER BY Problems =S
Linden
post Dec 29 2007, 09:20 PM
Post #1


Member
**
Posts: 51
OS: XP



Okay, I am working on a script that will display a table which shows peoples characters and their honor.

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 tongue.gif.

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 smile.gif.

Any help is much appreciated!! biggrin.gif

Thanks so much guys,

-Linden
Go to the top of the page
 
+Quote Post
Metallica
post Dec 30 2007, 02:02 PM
Post #2


Spyware Veteran
Group Icon
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.
Go to the top of the page
 
+Quote Post
Linden
post Dec 31 2007, 12:59 AM
Post #3


Member
**
Posts: 51
OS: XP



Thanks heaps smile.gif. The problem was the order I had the things listed >_>.

Now everything is how I want, I just need a little more help smile.gif.

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 sad.gif. Any Ideas?

Thanks biggrin.gif.

--Linden
Go to the top of the page
 
+Quote Post
Metallica
post Dec 31 2007, 02:43 AM
Post #4


Spyware Veteran
Group Icon
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.
Go to the top of the page
 
+Quote Post
Linden
post Jan 1 2008, 07:00 PM
Post #5


Member
**
Posts: 51
OS: XP



Thanks heaps smile.gif.
Any one else? that can help?
Go to the top of the page
 
+Quote Post
Metallica
post Jan 3 2008, 02:19 PM
Post #6


Spyware Veteran
Group Icon
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.
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies / Views Topic Information
No New Posts   1 / 491 4th January 2008 - 05:33 AM
Linden started - last by gunner12
No New Posts   2 / 408 1st July 2008 - 02:24 PM
gregsmart79 started - last by gregsmart79
No New Posts   2 / 856 14th July 2008 - 10:25 PM
Jack Wetson started - last by Ax238
No New Posts   4 / 144 29th October 2008 - 04:56 PM
sheegirl started - last by sheegirl

RSS 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.