Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 07-12-2005, 07:36 AM   #1 (permalink)
Addict
 
soma's Avatar
 
Location: USA
Getting multiple PHP variables using a single HTML form

I'm working on a small personal stock research tool, and I want to know if it is possible to get multiple php variable values from 1 html form. I'll try to better explain exactly what I mean:

Let's say I have a list of 5 stock symbols, each separated by a single space:

amd intc msft nvda atyt

Now let's say I copy all of them, and paste them into an html form and press the submit button. From here, is it possible to separate each of the symbols and define a variable to each one?

If what I'm saying does not make sense, please ask.
__________________
Having Girl Problems?
soma is offline  
Old 07-12-2005, 08:49 AM   #2 (permalink)
Insane
 
Location: West Virginia
Lets say your form field names are field1, field2, and field3...

You can do the following:
$newField1 = $_GET['field1'];
$newField2 = $_GET['field2'];
$newField3 = $_GET['field3'];

For a post, simply use $_POST. Another handy one is $_REQUEST which will grab the variable wether it be a POST, GET, or even COOKIE
__________________

- Artsemis
~~~~~~~~~~~~~~~~~~~~
There are two keys to being the best:
1.) Never tell everything you know
Artsemis is offline  
Old 07-12-2005, 02:10 PM   #3 (permalink)
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
I believe you're looking for the explode() function. It splits a string into an array on a specified string.

Code:
$data = "one two three four"
$result = array();
$result = explode(" ", $data);
The array $result now has the folowing values:

$result[0] = "one";
$result[1] = "two";
$result[2] = "three";
$result[3] = "four";
ratbastid is offline  
Old 07-12-2005, 03:14 PM   #4 (permalink)
Tilted
 
Location: Calgary, AB
You can also set the names/id on your form to be array values:

<input name="field[0]" type="text" value="123.4"/>
<input name="field[1]" type="text" value="456.7"/>
<input name="field[2]" type="text" value="789.0"/>

--or if you don't care about which index --

<input name="field[]" type="text" value="123.4"/>
<input name="field[]" type="text" value="456.7"/>
<input name="field[]" type="text" value="789.0"/>


then when you $_GET['field'] you can use it as an array
__________________
As soon as you stop living, you start dying....
wdevauld is offline  
Old 07-12-2005, 08:54 PM   #5 (permalink)
Crazy
 
Location: here and there
Quote:
Originally Posted by wdevauld
then when you $_GET['field'] you can use it as an array
keep in mind, $_GET is an array and can be treated as such (accessed by index or looped).
__________________
# chmod 111 /bin/Laden
theFez is offline  
Old 07-13-2005, 03:06 AM   #6 (permalink)
Insane
 
Location: West Virginia
Oops, just realized I misread the question. Looks like you got the answer needed though
__________________

- Artsemis
~~~~~~~~~~~~~~~~~~~~
There are two keys to being the best:
1.) Never tell everything you know
Artsemis is offline  
 

Tags
form, html, multiple, php, single, variables


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



All times are GMT -8. The time now is 12:44 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62