PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

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 Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old October 1st, 2002, 02:48 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
variable variables

ok, this ones been annoying me for a while now, I have a page which generates a list of items held by the user viewing it. This is done by looping through the query, and next to each item echoed is a checkbox, now the value of the checkbox is the same as the name of item, and the name of the checkbox is checkbox1, 2, 3 etc. going up for each item they have in their list. This form then goes to a new page, now what i need to do is echo out all the ones they selected. But because the name and value of the checkboxes which are being parsed through the form are variables, im having difficulty. Somehow i have to do a test to see which ones were parsed. Anyone have any ideas?

Reply With Quote
  #2  
Old October 1st, 2002, 03:31 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: variable variables

Well, you can handle this in a couple of ways...keeping the names you have, you would have to loop through and see if the variable exists..up to a maximum amount of variables..

php Code:
Original - php Code
  1. for($i = 1; $i < 30; $i++) {
  2.   if (isset ($_POST["checkbox$i"])) {
  3.      //it is set
  4.   }
  5. }


The other way to do it is to rename all your checkboxes into an array name...instead of calling your checkboxes checkbox1, checkbox2, and so one...make the name of all of them checkbox[]...then you can use a foreach to get the values...

php Code:
Original - php Code
  1. foreach ($_POST['checkbox'] as $value) {
  2.   echo "$value<BR>n";
  3. }



Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > variable variables


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway