ram4nd Posted January 11, 2009 Share Posted January 11, 2009 I would like to create a multidimensional array. Whith 2 existing arrays. Just put them together in 1 array. Theese are my arrays: $results1 = $mysql->doQueryA("SELECT name FROM category_id"); $results2 = $mysql->doQueryA("SELECT name FROM subcategory_id"); Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/ Share on other sites More sharing options...
dclamp Posted January 11, 2009 Share Posted January 11, 2009 Multidimensional array is not what your looking for. You just want 2 array merged together... try using array_merge() Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734593 Share on other sites More sharing options...
ram4nd Posted January 11, 2009 Author Share Posted January 11, 2009 Ok yes, that is right. If I want to put subcategories into categories then i have to do?: array_merge($categories, $subcategories) Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734594 Share on other sites More sharing options...
dclamp Posted January 11, 2009 Share Posted January 11, 2009 ah i see what you want to do. How is your table setup? Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734599 Share on other sites More sharing options...
ram4nd Posted January 11, 2009 Author Share Posted January 11, 2009 Umm, what do you mean by table setup? Sql table setup?: category - id name subcategory- id name category_id Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734602 Share on other sites More sharing options...
Mark Baker Posted January 11, 2009 Share Posted January 11, 2009 Umm, what do you mean by table setup? I think the point of the question is to determine whether a subcategory is associated with a specific category, because you may be able to execute a single SQL query to retrieve data from both tables in one go Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734622 Share on other sites More sharing options...
ram4nd Posted January 11, 2009 Author Share Posted January 11, 2009 Umm, ok it is not associated. It takes data sepperately from sql tables. Like in the post what i did before this. Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734764 Share on other sites More sharing options...
dclamp Posted January 11, 2009 Share Posted January 11, 2009 Umm, what do you mean by table setup? I think the point of the question is to determine whether a subcategory is associated with a specific category, because you may be able to execute a single SQL query to retrieve data from both tables in one go Yeah thats what i was getting at... Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734858 Share on other sites More sharing options...
Mark Baker Posted January 11, 2009 Share Posted January 11, 2009 Umm, ok it is not associated. category - id name subcategory- id name category_id suggests that it is associated, on category_id. Alternatively, you could use a UNION in your query: SELECT ID, NAME FROM CATEGORY UNION SELECT ID, NAME FROM SUBCATEGORY Link to comment https://forums.phpfreaks.com/topic/140373-multidimensional-array/#findComment-734862 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.