SaLing007 Posted September 28, 2008 Share Posted September 28, 2008 Hello guys, Maybe someone can help me to sort this out with my code please? Well, first of all I have got FOREACH and it doesn't work well. What I am trying to do is, I have some rows receiving from mysql. Sample: from table Users, rows>Name, Email, Id and Ip. I am getting it displayed, whatsoever when I opened foreach as a row from Name to Ip I need to include another foreach inside the one I just wrote. The other foreach has to get results from anoter table in db. Here like a tiny sample: $result = $db->get_results("SELECT * FROM Users WHERE UserId = '$link_id'"); foreach($result as $row) { $nm = $row->Name; $eml = $row->Name; $id = $row->UserId; $ip = $row->Ip; *Here is html table and displaying all info <td>' . $id . '</td> $result2 = $db->get_results("SELECT * FROM Groups WHERE Group_ID = '$link_id'"); foreach($result2 as $row) { $something = $row->Group_NAME; <table> <tr><td>' . $something . '</td></tr> </table> } <td>' . $ip . '</td> } But this way it does not work. What I am doing wrong? And the second thing is that I have this code between html: $result2 = $db->get_results("SELECT * FROM Groups ORDER BY Group_ID"); foreach($result2 as $row) { $grp_id = $row->Group_ID; $grp_nm = $row->Group_NAME; $value = 'subscribe_view.php?group=' . $grp_id; $option = '<option value="' . $value . '">' . $grp_nm . '</option>'; echo $option; } So as you noticed I need to get drop down options as a rows. This is the way I can have exact names of groups from table. For the values I have javascript which transfers me selection to the value link (maybe there is another way to do this with php?). But When I click for example on one of those options aka. Sounding, it refreshes the page {as it has to be on the same page} and the selected option has not been assigned. Does anyone of you guys know how can I have <selections> html drop down list to remember selection? Please help me so I can continue with my coding. I am desperate with that And massive THANK YOU to those who have their say. All your help are really appreciated. Thank you all! S Link to comment https://forums.phpfreaks.com/topic/126142-please-help-problems-with-foreach-and-how-to-remember-selected/ Share on other sites More sharing options...
SaLing007 Posted September 28, 2008 Author Share Posted September 28, 2008 Hello again, Well, With foreach is all sorted so by now I have just one question. How can drop down can assign 'selected'? Thank you Link to comment https://forums.phpfreaks.com/topic/126142-please-help-problems-with-foreach-and-how-to-remember-selected/#findComment-652325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.