anikwa Posted June 1, 2013 Share Posted June 1, 2013 Well, the forums are the first thing I'm doing but I'm having an error with my SQL. SELECT * FROM categories_tbl LEFT JOIN forums_tbl ON (forums_tbl.parent_id = categories_tbl.category_id) WHERE category_id=parent_id The results of the var_dump: array(2) { [0]=> array(18) { ["category_id"]=> string(1) "1" [0]=> string(1) "1" ["category_name"]=> string(7) "General" [1]=> string(7) "General" ["category_parent_id"]=> string(1) "0" [2]=> string(1) "0" ["forum_id"]=> string(1) "1" [3]=> string(1) "1" ["forum_name"]=> string( "Welcome!" [4]=> string( "Welcome!" ["forum_created"]=> string(19) "2013-05-31 18:25:46" [5]=> string(19) "2013-05-31 18:25:46" ["forum_legend"]=> string(27) "Introduce yourself in here!" [6]=> string(27) "Introduce yourself in here!" ["parent_id"]=> string(1) "1" [7]=> string(1) "1" ["forum_createdby"]=> string(7) "Akhaten" [8]=> string(7) "Akhaten" } [1]=> array(18) { ["category_id"]=> string(1) "2" [0]=> string(1) "2" ["category_name"]=> string(9) "Computers" [1]=> string(9) "Computers" ["category_parent_id"]=> string(1) "0" [2]=> string(1) "0" ["forum_id"]=> string(1) "2" [3]=> string(1) "2" ["forum_name"]=> string(15) "PHP is Awesome!" [4]=> string(15) "PHP is Awesome!" ["forum_created"]=> string(19) "2013-05-31 18:25:46" [5]=> string(19) "2013-05-31 18:25:46" ["forum_legend"]=> string(18) "Let's all use PHP." [6]=> string(18) "Let's all use PHP." ["parent_id"]=> string(1) "2" [7]=> string(1) "2" ["forum_createdby"]=> string(5) "xLink" [8]=> string(5) "xLink" } } Link to comment https://forums.phpfreaks.com/topic/278666-building-integrated-forums-to-my-website/ Share on other sites More sharing options...
mac_gyver Posted June 1, 2013 Share Posted June 1, 2013 what error are you having? nothing in your post indicates exactly what is wrong with the result you got v.s. what you expect. the only things I can tell from what you posted is you are repeating the join condition being used in the ON term a second time in the WHERE term, which is just redundant and unnecessary. you are also use a *_fetch_array() statement in your php code and getting both the associative and numerical indexes. since you probably only want the associative indexes, use a *_fetch_assoc() statement. Link to comment https://forums.phpfreaks.com/topic/278666-building-integrated-forums-to-my-website/#findComment-1433575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.