The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

Select each row ordering by name

Hey guys,

I have a table, with an ID row, some rows that I want to get information from(match1, match2, match3, etc. are their names..up to match30, although all these rows are basically pointless in this question), and also a lastname row..

Now all I want to be able to do is go through the rows in order by last name..this means like a SELECT * FROM query where I can get each result individually..I'll try to give an example of this..

PHP Code:

$sql = mysql_query("SELECT * FROM information WHERE grade='9' ORDER BY lastname asc");
$numrows = mysql_num_rows($sql);
for ($i=0; $i <= $numrows; $i++)
{
while ($row = mysql_fetch_array($sql))
{
// Ok, now would this code run through like 100 times if there were 100 rows from grade='9' ?
// If so, then would the first row select the last name Aardvark first, etc in alphabetical order?
}
}