Jump to content

Number Increment Next To MySQL Querys


CMellor

Recommended Posts

Hello, I have a question about PHP and I hope I can get some help.

I have a simple bit of code that lists the members on my forum.

[code]<?php
include("include/dbconnect.php");

$query = mysql_query("SELECT * FROM ibf_members") or die(mysql_error());
while($row = mysql_fetch_array($query)) {
  echo $row['members_display_name'] .'<br />';
}
?>[/code]

I am building a ranking page on my site, where they will be listed in order of most points (I have a points hack) and I wanted to list each of them with a number next to it, but not to use their ID because I want to list it from 1-10.

[code]<?php
for($count = 1; $count <= 10; $count++) {
  echo $count .'<br />';
}
?>[/code]

I know this bit of code creates a 1-10 list and I was trying to use it in the other code I provided to list each DB query as a number. I hope I make sense, I'm not great at talking about coding.

Thanks for your time.

Chris
Link to comment
Share on other sites

It would certainly make sense to SELECT what you need ... for example, to get only the 10 highest point holders ordered in descending order:

[code]$query = "SELECT member_name from your_table_name ORDER by points DESC LIMIT 10";[/code]
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.