turpentyne Posted August 28, 2010 Share Posted August 28, 2010 Hey there. Not sure how to word this. I've been flying blind as a newbie trying to figure out some pagination for a left joined query. I've got syntax errors trying to set up the SELECT COUNT function that adds up the results of the search on a previous page so it knows how many results matched both tables. Right now, I've got this mess, and it's giving me a syntax error, "You have an error in your SQL syntax; .... near 'LEFT JOIN plantae ON (descriptors.plant_id = plantae.pla' at line 12" $data = "Select (SELECT COUNT(*) FROM descriptors ) AS count1, (SELECT COUNT(*) FROM plantae ) AS count2 LEFT JOIN plantae ON (descriptors.plant_id = plantae.plant_name) WHERE `leaf_shape` LIKE '%$select1%' AND `leaf_venation` LIKE '%$select3%' AND `leaf_margin` LIKE '%$select4%'"; $result = mysql_query ($data); if (!$result) { die("Oops, my query failed. The query is: <br>$data<br>The error is:<br>".mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/211958-select-counting-of-two-tables-to-paginate-their-query-results/ Share on other sites More sharing options...
turpentyne Posted August 28, 2010 Author Share Posted August 28, 2010 whoah! wait. got a little lucky. But still problems with the pagination. I suppose I'll need to post a new topic for that. I changed the code to: $data = "SELECT COUNT(*) FROM descriptors LEFT JOIN plantae ON (descriptors.plant_id = plantae.plant_name) WHERE `leaf_shape` LIKE '%$select1%' AND `leaf_venation` LIKE '%$select3%' AND `leaf_margin` LIKE '%$select4%'"; $result = mysql_query ($data); Link to comment https://forums.phpfreaks.com/topic/211958-select-counting-of-two-tables-to-paginate-their-query-results/#findComment-1104639 Share on other sites More sharing options...
jcbones Posted August 28, 2010 Share Posted August 28, 2010 http://www.phpfreaks.com/tutorial/basic-pagination Link to comment https://forums.phpfreaks.com/topic/211958-select-counting-of-two-tables-to-paginate-their-query-results/#findComment-1104649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.