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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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()); Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.