Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-17-2011, 02:46 PM   #1
Member (8 bit)
 
Join Date: Jun 2010
Posts: 199
Not Sorting my db

My display is not being sorted as you can see on
this page. What am I doing wrong?

PHP Code:
<?php
$sql 
mysql_query("SELECT * FROM `nyyschedule` ORDER BY `gameid` ASC");

while( 
$row mysql_fetch_assoc($sql) ) { 
    echo 
'<tr class="info" align="center">
    <td>' 
$row['date'] . '</td> 
    <td>' 
$row['opponent'] . '</td>
    <td>' 
$row['time'] . '</td> 
    <td>' 
$row['HP'] . '</td> 
    <td>' 
$row['AP'] . '</td>'
}
?>

Last edited by RobbieG1977; 10-17-2011 at 02:46 PM. Reason: made a mistake
RobbieG1977 is offline   Reply With Quote
Old 10-17-2011, 03:21 PM   #2
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
There are a few additional mistakes, on top of what your edit comment suggests.

First, you're not closing any of your statements. The only statements closed properly are the $sql = and the last $['AP'] statements.

Second, what column are you attempting to sort by? What does your database look like? When you specify "ORDER BY" in your SQL statement, it will sort your results by that column.
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 10-17-2011, 04:23 PM   #3
Member (8 bit)
 
Join Date: Jun 2010
Posts: 199
Updated my errors
PHP Code:
<?php
$sql 
mysql_query("SELECT * FROM `nyyschedule` ORDER BY `gameid` ASC");

while( 
$row mysql_fetch_assoc($sql) ) { echo '<tr class="info" align="center">;
    <td>' 
$row['date'] . '</td>;
    <td>' 
$row['opponent'] . '</td>;
    <td>' 
$row['time'] . '</td>;
    <td>' 
$row['HP'] . '</td>;
    <td>' 
$row['AP'] . '</td>'
}
?>
Are they all correct?

I am sorting it by the 'gameid.'
RobbieG1977 is offline   Reply With Quote
Old 10-17-2011, 05:54 PM   #4
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Your syntax is correct.

However, I can't determine anything beyond that since your link is dead and I know nothing about your particular database. You'll have to provide some more information.
Force Flow is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:48 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2