perik Posted January 21, 2010 Share Posted January 21, 2010 Hi! I have a page built in php for different projects within culture and arts. In one part of the page the members of the page can presentate their projects. In this part I would like to have a userlist with the possibility to check which other members you have collaborated with in different projects like in the picture below. The problem is when I check several checkboxes there will still just show up one collaboration on the page. Heres an more detailed explanation: I get the this userlist with the code: // FROM $projectmenu_selcatNY = ''; if ($sql->db_Select('user', 'user_id, user_name', ' GROUP BY user_id', 'nowhere', false)) { while ($projectmenu_row = $sql->db_Fetch()) { extract($projectmenu_row); $projectmenu_selcatNY .= "$user_name<input type='checkbox' name='project_body' value='$user_name $user_id'<br "; if ($user_id == $projectmenu_projectcat) { } $projectmenu_selcatNY .= '>' . $tp->toFORM($projectmenu_bortmedborjan2[2], false) . '</option>'; } } $projectmenu_selcatNY .= '</select>'; // TO 2) And this results in a page like below with lists of the collaborations that are checked in the list: With the code: SC_BEGIN project_VIEW_BODY global $tp,$user_id_project,$project_body,$user_id_project,$project_author,$projectmenu_postername,$user,$user_name,$projectmenu_postername; return "<a href='".e_BASE."user.php?id.$project_body'>$project_body</a>"; SC_END Where project_VIEW_BODY is a shortcode for a templatefile. And $project_body is the value from the checkbox. Heres is also a picture of the database: MY QUESTION: The problem is when I check several checkboxes there will still just show up one collaboration on the page. What shall I change in the code to be able to make several users to get registrated in the database? So if I for example check: Katapult V Per3 V It ends up with a database that looks like: project_body: Katapult, per3 Thanks a lot for help!!! Perik Quote Link to comment Share on other sites More sharing options...
perik Posted January 22, 2010 Author Share Posted January 22, 2010 I have now changed this in the code name='project_body[]' with new code: // FROM $projectmenu_selcatNY = ''; if ($sql->db_Select('user', 'user_id, user_name', ' GROUP BY user_id', 'nowhere', false)) { while ($projectmenu_row = $sql->db_Fetch()) { extract($projectmenu_row); $projectmenu_selcatNY .= "$user_name<input type='checkbox' name='project_body[]' value='$user_name'<br "; if ($user_id == $projectmenu_projectcat) { } $projectmenu_selcatNY .= '>' . $tp->toFORM($projectmenu_bortmedborjan2[2], false) . '</option>'; } } $projectmenu_selcatNY .= '</select>'; // TO when Im checking a name in the user list it will now registrate the word "Array" in the database instead. how do I use arrays and write the code so it writes several names like: project_body: Katapult, per3 in the database instead of Array or overwriting the names? as you probably understand Im a newbie in php Thanks for your help! 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.