antonyfal Posted May 7, 2013 Share Posted May 7, 2013 Hi. I have this simple 2 queries that i am trying to get the output of two table queries syncronised.. if(isset($_GET['loadLists'])) { if($needAuth == 1 && !is_logged()) return 'you must be logged in to view this list.'; else $sqlWhere = ''; $current_user_id = (__isset('multiuser') == 1)?intval($_SESSION['userid']):0; $q = $db->dq("SELECT * FROM todo_lists $sqlWhere ORDER BY ow ASC, id ASC"); while($row = mysql_fetch_assoc($q)) { $ncurconfig = $db->dq("SELECT * FROM todo_lists_setting WHERE list_id =? AND user_id=?", array($row['id'], $current_user_id)); $sett = $mysql_fetch_assoc($ncurconfig); echo '<li id="list_'.$row['id'].'" rel="'.$sett['notify'].'_'.$sett['showcompl'].'_'.$sett['sorting'].'_'.$sett['shownotes'].'_'.$sett['showdates'].'" class="tab"><a href="#list/'.$row['id'].'" rel="'.$row['id'].'" title="'.htmlarray($row['name']).'"><span>'.htmlarray($row['name']).'</span></a></li>'; } } this should output 4 tabs with different names, and each with their own "rels" settings... Only the first rel is output the other tabs have only "____".. I dont know how to join or union queries, but i dont think that they are relevant here? thanks in advance.. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 7, 2013 Share Posted May 7, 2013 A JOIN is definitely relevant. YOu should never ever do queries in loops. You want to do an INNER JOIN on your settings to the lists table. Once you get that working (Try doing the query directly in mysql/phpmyadmin) we can help with any other issues. Quote Link to comment Share on other sites More sharing options...
antonyfal Posted May 7, 2013 Author Share Posted May 7, 2013 Hi Jesica.. I see what you meaning. If i can here something like this: $result = mysql_query("SELECT * FROM todo_lists INNER JOIN todo_lists_setting ON todo_lists.id=todo_lists_setting.list_id WHERE todo_lists_setting.user_id = '$current_user_id'"); while($row=mysql_fetch_array($result)) { echo '<li id="list_'.$row['id'].'" rel="'.$row['notify'].'_'.$row['showcompl'].'_'.$row['sorting'].'_'.$row['shownotes'].'_'.$row['showdates'].'" class="tab"><a href="#list/'.$row['id'].'" rel="'.$row['id'].'" title="'.htmlarray($row['name']).'"><span>'.htmlarray($row['name']).'</span></a></li>'; } is this correct? Quote Link to comment Share on other sites More sharing options...
antonyfal Posted May 7, 2013 Author Share Posted May 7, 2013 here is the full example: it only outputs the first tab and its setting. The other tabs dont show.. if(isset($_GET['loadLists'])) { if($needAuth == 1 && !is_logged()) return 'you must be logged in to view this list.'; $current_user_id = (__isset('multiuser') == 1)?intval($_SESSION['userid']):0; $q = $db->dq("SELECT * FROM todo_lists INNER JOIN todo_lists_setting ON todo_lists.id=todo_lists_setting.list_id WHERE todo_lists_setting.user_id = '$current_user_id'"); while($row = mysql_fetch_assoc($q)) { echo '<li id="list_'.$row['id'].'" rel="'.$row['notify'].'_'.$row['showcompl'].'_'.$row['sorting'].'_'.$row['shownotes'].'_'.$row['showdates'].'" class="ytt-tabi"><a href="#list/'.$row['id'].'" rel="'.$row['id'].'" title="'.htmlarray($row['name']).'"><span>'.htmlarray($row['name']).'</span></a></li>'; } } Quote Link to comment Share on other sites More sharing options...
antonyfal Posted May 8, 2013 Author Share Posted May 8, 2013 My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. Your solution or hint does not work! and your method of teaching? is questionable.. Some of us learn by the solution and how it was achieved.. here you just threw me in another direction and waisted a day.. and left the scene.. Is there anybody else that can help!!!!! Quote Link to comment Share on other sites More sharing options...
Barand Posted May 8, 2013 Share Posted May 8, 2013 Can you provide table structures and data? (table dumps) Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 8, 2013 Share Posted May 8, 2013 Your solution or hint does not work! and your method of teaching? is questionable.. Some of us learn by the solution and how it was achieved.. here you just threw me in another direction and waisted a day.. and left the scene.. Is there anybody else that can help!!!!! It's a signature dude. I didn't leave because I wasn't willing to help. I left because I had work to do. You didn't "waste" (that's how it's spelled btw) anything because you learned how to do a JOIN which was what was needed. 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.