PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 8th, 2008, 01:01 AM
simon_r2d2 simon_r2d2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 28 simon_r2d2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 21 m 4 sec
Reputation Power: 0
Multidimensional Array as Checkbox Value

I have a nested repeat region in a PHP Page which displays something like this:

Line Manager Name
Employee Name
City
City
City
Line Manager Name
Employee Name
City
City
City

Each of the above have their own ID value pulled from a MySQL Database. Under the Employee Name is a list of Cities, again with an ID. Alongside each of the cities is a checkbox. What I need to be able to do is pass through all three ID's (Line Manager, Employee and City) as an array as the value for an individual checkbox.

I think I understand that the checkbox needs to be defines as something like:

Code:
<input name="$arr_values[][][]" type="checkbox" id="$arr_values[][][]" value="" />


But, as you can see I can't figure out how to assign the three values to each element of the array.

I want to end up with:
$arr_values[line_mgr_id][employee_id][city_id]

Can anyone help??

Simon

Reply With Quote
  #2  
Old August 8th, 2008, 09:07 AM
simshaun's Avatar
simshaun simshaun is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2008
Location: North Carolina
Posts: 2,674 simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)simshaun User rank is General 25th Grade (Above 100000 Reputation Level)  Folding Points: 59700 Folding Title: Beginner FolderFolding Points: 59700 Folding Title: Beginner FolderFolding Points: 59700 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 1 Day 20 h 35 m 37 sec
Reputation Power: 2673
Assuming your loop looks something like this, its as simple as echo-ing the variable.

PHP Code:
<?
while ($row mysql_fetch_assoc($result)){ // line managers
    
$manager_id $row['manager_id'];
    
$manager_name $row['manager_name'];
    
$employee_id $row['employee_id'];
    
$employee_name $row['employee_name'];

    echo 
$manager_name,'<br />',str_repeat('&nbsp;'4),$employee_name,'<br />';

    
mysql_data_seek($result20); // since this result will be used more than once
    
while ($cities mysql_fetch_assoc($result2)){ // cities
        
$city_id $cities['id'];
        
$city_name $cities['name'];

        echo 
str_repeat('&nbsp;'8),"<input type=\"checkbox\" name=\"$values[$manager_id][$employee_id][]\" id=\"$manager_id-$employee_id-$city_id\" value=\"$city_id\" /> $city_name<br />\n";
    }
}
?>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Multidimensional Array as Checkbox Value

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap