ayok Posted August 7, 2007 Share Posted August 7, 2007 Hi, Another question. I want to have a page with categorized items, and also limit the divide the page into sub pages (with "previous 1 2 3 next" buttons), but I couldn't do it. I have this code: "SELECT products.*,category.name FROM products LEFT JOIN category on product.categorized=category.category_number LIMIT $offset,$limit WHERE category_number='$id'") LIMIT and WHERE doesn't work. But if I delete "LIMIT $offset,$limit", I have a long page. Anybody can help me to solve this? Thank you, ayok Link to comment https://forums.phpfreaks.com/topic/63684-solved-select-left-join-limit-where/ Share on other sites More sharing options...
KrisNz Posted August 7, 2007 Share Posted August 7, 2007 you've got them round the wrong way. the WHERE part should go before the LIMIT part. Link to comment https://forums.phpfreaks.com/topic/63684-solved-select-left-join-limit-where/#findComment-317397 Share on other sites More sharing options...
ayok Posted August 7, 2007 Author Share Posted August 7, 2007 Hi kris, I've switched where and limit, but it still doesn't work. Thanks ayok Link to comment https://forums.phpfreaks.com/topic/63684-solved-select-left-join-limit-where/#findComment-317428 Share on other sites More sharing options...
jitesh Posted August 7, 2007 Share Posted August 7, 2007 $sql = "SELECT products.*,category.name FROM products LEFT JOIN category on (product.categorized=category.category_number) WHERE category_number=".$id." LIMIT ".$offset.",".$limit; $so = mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/63684-solved-select-left-join-limit-where/#findComment-317432 Share on other sites More sharing options...
ayok Posted August 7, 2007 Author Share Posted August 7, 2007 Thx jitesh, but it still doesn't work. The error message "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1" seems it doesn't allow me to put LIMIT with WHERE. ayok Link to comment https://forums.phpfreaks.com/topic/63684-solved-select-left-join-limit-where/#findComment-317443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.