multiple mysql queries into one php two-dimensional array -
I'm refactoring my code and just a snag. The first query in the code below receives tab_ID of the latest submitted tabs. The second query gets the details of each tab In my old way of doing this, I embed PHP and HTML and it was actually a totally mess. Right now I want to merge 2 questions in 1 and / or load it into an array.
Ask for free and / or masculine
function get_newest_tabs () {$ db_open; $ Sql = "SELECT tab_id, song_id, user_id from FROM tab, time_added DESC by ORDER". "LIMIT 15"; $ Result = mysql_query ($ sql) or die ("Error - Latest tab function:" .mysql_error ()); {$ (= $; $ I & lt; mysql_num_rows ($ result); $ i ++) {$ tab_id = mysql_result ($ result, $ i, "if mysql_num_rows ($ result) & gt; 0) Tab_id "); $ Db_open; $ Sql = "SELECT tabs.tab_id, tabs.tab_version, tabs.number_of_hits, artist.artist_name, users.user_alias, songs.song_name, tabs, users, artists, where songs tabs.time_added tabs.tab_id = '". $ Tab_id '' And tab.giser_id = users.user_id and tab SAGIID = songs.Cong_ID and songs.artist_id = artist Cartist_aidi "; $ Result2 = mysql_query ($ sql) or die (" Error - i3p mysql-4: ".mysql_error ()); if (mysql_num_rows ($ result2) == 1) {$ song_name = mysql_result ($ result 2, 0, "songs.song_name"); $ Artist_name = mysql_result ($ result 2, 0, "artist.artist_name"); $ User_alias = mysql_result ($ result 2, 0, "users.user_alias"); $ Tab_version = mysql_result ( $ result 2, 0, "tabs.tab_version"); $ Number_of_hits = mysql_result ($ result 2, 0, "tabs.number_of_hits"); $ Time_added = mysql_result ($ result 2, 0, "tab. Taim_ added");} }}}
I recommend selection from multiple tables instead of using Join Would you like to tab tabi May include receiving.
Then you can do a loop like:
while ($ line = mysql_fetch_array ($ result)) {$ tab [$ line ['Tab_id']] = $ line; }
Unless you have a user / song / artist per tab, you will find an array of your data.
Comments
Post a Comment