Jump to content

Recommended Posts

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.

bild1.jpg

 

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:

bild2.jpg

 

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:

bild3.jpg

 

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/189369-help-with-php/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/189369-help-with-php/#findComment-999852
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.