Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-14-2005, 03:47 PM
Jerry's Avatar
WebProWorld Pro
 

Join Date: Nov 2003
Location: Northern Texas
Posts: 259
Jerry RepRank 0
Default multiple values from form in php

Is there any way to send form values as an array to a php script? I need to build a page that "knows" how many calendars to display, and am looking for the simplest method possible to send the caledar id fields to the script.

I've tried:
somepage.php?calid=1&calid=2...


Obviously the second calid simply negates the first. is there a way to send this information in a similar fashion, or will it be necessary to set it up as something like:

somepage.php?calid1=1&calid2=2...

Any advice is appreciated
Reply With Quote
  #2 (permalink)  
Old 09-14-2005, 05:56 PM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

Hi,

How about combining all the ids into a string from the array using implode and passing that as the parameter.

e.g. test.php?calid=1;2;3;4;5;6

then use explode to seperate them back into an array?
i know it's not a very neat url but hey if it works. or am i misunderstanding the question?
Reply With Quote
  #3 (permalink)  
Old 09-14-2005, 07:27 PM
Jerry's Avatar
WebProWorld Pro
 

Join Date: Nov 2003
Location: Northern Texas
Posts: 259
Jerry RepRank 0
Default

You had it right on the mark, and if I were more experienced in php, i probably would have gone that way.

Instead, i used an array of calid's, as such:

somepage.php?calid[]=123&calid[]=456...

then it's as simple as using a for each to go through it as in the following example:
Code:
$calids = $_GET['calid'];

foreach ($calids as $name => $value){
  //work some php magic here...
  print $value;
  //and the rest of the magic
}
Also not a pretty url, but it works
Reply With Quote
  #4 (permalink)  
Old 09-20-2005, 03:34 PM
WebProWorld Member
 

Join Date: Sep 2005
Posts: 25
web_hosting_world RepRank 0
Default

Use $_POST instead. form method to post. The url will be clean.
__________________
Web-Hosting-World.com
Find your Web Host Here
Top 10 Web Hosts
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0