Order by name

Reply

Join Date: Nov 2004
Posts: 259
Reputation: sam1 is an unknown quantity at this point 
Solved Threads: 1
sam1's Avatar
sam1 sam1 is offline Offline
Posting Whiz in Training

Order by name

 
0
  #1
Mar 17th, 2009
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

  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);
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,373
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 166
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Order by name

 
0
  #2
Mar 17th, 2009
  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.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC