943,987 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 361
  • PHP RSS
Mar 17th, 2009
0

Order by name

Expand Post »
hi,

i have this script, which i want to order by name. but when i say order by name asc at the end i get error:

here is the bit i am changing

PHP Syntax (Toggle Plain Text)
  1. $genre_id = $_GET['id'];
  2.  
  3. $items = ITEMS_PER_PAGE;
  4.  
  5. if(isset($_GET['page']))
  6. {
  7. $offset = $_GET['page'];
  8. $offset *= $items;
  9. $query = 'select * from artist where genre_id = '.mysql_real_escape_string($genre_id)." limit $offset,$items";
  10. }
  11. else
  12. {
  13. $query = 'select * from artist where genre_id = '.mysql_real_escape_string($genre_id);
  14. }
  15.  
  16. $allArtists = mysql_query($query);
Reputation Points: 10
Solved Threads: 1
Posting Whiz
sam1 is offline Offline
300 posts
since Nov 2004
Mar 17th, 2009
0

Re: Order by name

php Syntax (Toggle Plain Text)
  1. $genre_id = $_GET['id'];
  2. $items = ITEMS_PER_PAGE;
  3. if(isset($_GET['page']))
  4. {
  5. $offset = $_GET['page'];
  6. $offset *= $items;
  7. $query = 'select * from artist where genre_id = '.mysql_real_escape_string($genre_id)." limit $offset,$items";
  8. }
  9. else
  10. {
  11. $query = 'select * from artist where genre_id = '.mysql_real_escape_string($genre_id);
  12. }
  13. $allArtists = mysql_query($query);
[code=php] tags, syntax highlighting

select * doesnt allow "us" to see the column names, Is there a column "name"
$items = // are you sure about this definition it doesnt look right
$items = $_GET['ITEMS_PER_PAGE']; // looks more usual to me
what is the exact error message
and where did you put the order by clause in this code
Last edited by almostbob; Mar 17th, 2009 at 11:08 am.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: unable to connect to MYSQL via PHP
Next Thread in PHP Forum Timeline: If Statement Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC