Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-21-2010, 05:16 PM Help with php ...
Novice Talker

Posts: 14
Trades: 0
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:
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:
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:
Quote:
Katapult V
Per3 V
It ends up with a database that looks like:
Quote:
project_body:
Katapult, per3
Thanks a lot for help!!!

Perik
perik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-21-2010, 10:03 PM Re: Help with php ...
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
You'll need the tip at http://www.php.net/manual/en/faq.htm...aq.html.arrays . I think with that, based on the code above, you'll be able to resolve your issue, but if you get stuck or don't fully understand it, then let us know.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-22-2010, 08:27 AM Re: Help with php ...
Novice Talker

Posts: 14
Trades: 0
thanks for your reply

ok I have now changed the code to:
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 write the code so it writes several names like:
Quote:
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!
perik is offline
Reply With Quote
View Public Profile
 
Old 01-22-2010, 08:59 AM Re: Help with php ...
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Yes, when you add the brackets [] php will automatically create an array for you. You can access it's values "the normal way", as in

PHP Code:
$arr// your array that you get from the POST data
echo $arr[0]; // echo first element
echo $arr[1]; // echo seccond element
echo $arr[2]; // echo third element

// and so on 
And when posting code in the future, please use the php tags, [ php]your code here[ /php] (without the spaces).
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-22-2010, 09:37 AM Re: Help with php ...
Novice Talker

Posts: 14
Trades: 0
i think the script where Im writing into the database is somewhere here?
PHP Code:
        // New record so add it
        // check for duplicate
        
if (!$sql->db_Select("projectmenu_projects""project_id""where project_name='" $tp->toDB($_POST['project_name']) . "'"""false))
        {
            
$projectmenu_args "'0',
        '" 
$tp->toDB($_POST['project_name']) . "',
        '" 
USERID "." USERNAME "',
        '" 
$tp->toDB($_POST['project_servings']) . "',
        '" 
$tp->toDB($_POST['project_preptime']) . "',
        '" 
$tp->toDB($_POST['project_ingredients']) . "',
        '" 
$tp->toDB($_POST['project_body']) . "',
        '" 
$tp->toDB($_POST['project_source']) . "',
        '" 
$tp->toDB($_POST['project_nutrition']) . "',

//
// some code 
// some code 
// some code 
//

    else
    {
        // Update existing
        
$projectmenu_args = "
        
project_name='" . $tp->toDB($_POST['project_name']) . "',

        
project_servings='" . $tp->toDB($_POST['project_servings']) . "',
        
project_preptime='" . $tp->toDB($_POST['project_preptime']) . "',
        
project_ingredients='" . $tp->toDB($_POST['project_ingredients']) . "',
        
project_body='" . $tp->toDB($_POST['project_body']) . "',
        
project_source='" . $tp->toDB($_POST['project_source']) . "',
        
project_nutrition='" . $tp->toDB($_POST['project_nutrition']) . "',
        
project_category='" . intval($_POST['projectmenu_select']) . "',
        
project_approved='" . $project_approved . "'
can that be? what shall I change?
perik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with php ...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33037 seconds with 12 queries