AlbumFiend Posted August 20, 2009 Share Posted August 20, 2009 I've got a variable that's like: $extra_alb_qry .= " ORDER BY `id` DESC"; and a variable that's like: $extra_alb_qry .= " AND `cat_id` = " . $_GET['genre']; Both of these work, but I want to change the 2nd one so it does the same thing but also has ORDER BY `id` DESC in it also, each time I edit it though it ends up pulling no data. Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/ Share on other sites More sharing options...
Daniel0 Posted August 20, 2009 Share Posted August 20, 2009 Cool story. Thanks for letting us know. Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902839 Share on other sites More sharing options...
AlbumFiend Posted August 20, 2009 Author Share Posted August 20, 2009 My question was how would I arrange the second $extra_alb_qry so that it would also ORDER BY ? Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902850 Share on other sites More sharing options...
MadTechie Posted August 20, 2009 Share Posted August 20, 2009 Erm.. maybe like this $extra_alb_qry .= " AND `cat_id` = " . $_GET['genre']; $extra_alb_qry .= " ORDER BY `id` DESC"; Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902865 Share on other sites More sharing options...
mikesta707 Posted August 20, 2009 Share Posted August 20, 2009 $extra_alb_qry .= " AND `cat_id` = " . $_GET['genre']; $extra_alb_qry .= " ORDER BY `id` DESC"; ? I don't get what your problem is so im with dan. cool story bro, i guess... Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902866 Share on other sites More sharing options...
AlbumFiend Posted August 20, 2009 Author Share Posted August 20, 2009 I was asking if it were possible to combine them in the same variable, such as: $extra_alb_qry .= " ORDER BY `id` DESC AND `cat_id` = " . $_GET['genre']; This doesn't work, and I also tried adding it to the end which didn't work either. Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902868 Share on other sites More sharing options...
Daniel0 Posted August 20, 2009 Share Posted August 20, 2009 http://dev.mysql.com/doc/refman/5.1/en/select.html The WHERE clause comes before the ORDER BY clause. Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902871 Share on other sites More sharing options...
MadTechie Posted August 20, 2009 Share Posted August 20, 2009 Please note that mikesta707 and I BOTH used the same order! that should work! if you still have problems then please let us know what the problem is; "This doesn't work" is truly not helpful, I could reply "it does for me" or "theirs a problem then" which helps just as much, I'll have to assume that $_GET['genre'] isn't set.. echo out the query and check.. also turn on error reporting and use mysql_error(); for more details see Daniel0 post that points to the manual, Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902881 Share on other sites More sharing options...
Daniel0 Posted August 20, 2009 Share Posted August 20, 2009 Please note that mikesta707 and I BOTH used the same order! that should work! if you still have problems then please let us know what the problem is; "This doesn't work" is truly not helpful, I could reply "it does for me" or "theirs a problem then" which helps just as much, Yeah he put it together the other way around though. That's why it doesn't work. Link to comment https://forums.phpfreaks.com/topic/171207-pulling-mysql-info/#findComment-902883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.