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
Help with PHP form processing
Old 08-09-2004, 10:24 PM Help with PHP form processing
Average Talker

Posts: 15
Trades: 0
Is there a way to target only certain form elements for reading?

I'm looking to pluck a value out of the form, and I know that the value I'm looking for will either be in field 10,20,30,40,50 ... and so on. The field I'm targeting will always be a multiple of ten.

At present I'm parsing all of the fields until I find it, but this seems wasteful, as I only need to search every tenth field.

On a related note, is there a maximum limit (chars) that PHPwill accept. In other words, can a form have 500 fields?

Thank you.
new_PHP_er is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-10-2004, 04:58 AM
Ultra Talker

Posts: 377
Trades: 0
i think you'd better use JavaScript for that... you may target a element you want using it's name, or using special JS's arrays...
__________________
andrews_john

Please login or register to view this content. Registration is FREE
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 08-10-2004, 07:39 AM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
nah, lets say your fields are named;

var1
var2
var3...... (etc)

Then a control field that has the maximum number, lets say you have 100 fields, its value will be 100;

vartotal value="100"

You could then do this in PHP;

for($i=10;$i<=$_POST['vartotal'];$i++) {
if($_POST['var'.$i]=="what_I_am_looking_for") {
do stuff...
}
}
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-10-2004, 10:11 AM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Trades: 0
I assume you're using a for loop to do this. How about getting the loop to count (say) from 0 to 10 instead of 0 to 1000, then mulitplying:
PHP Code:
for($i=0$i<11$i++)
{
if(
$field[($i*10)).....

Or using if instead:
PHP Code:
if($fieldnum 10 ==0)
{
Process field

__________________

Please login or register to view this content. Registration is FREE
- Everything a webmaster needs - for free

Please login or register to view this content. Registration is FREE
- Free web hosts reviewed and rated

Please login or register to view this content. Registration is FREE
- Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile
 
Old 08-10-2004, 12:29 PM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Trades: 0
Hi,

I would make all the fields in the form part of the same array, and then run a for loop to check each multiple of 10. The form processing code would go inside the for loop.

Conker
__________________

Please login or register to view this content. Registration is FREE
- Affordable feature-packed remotely hosted message boards!

Last edited by conkermaniac; 08-10-2004 at 12:32 PM..
conkermaniac is offline
Reply With Quote
View Public Profile
 
Old 08-10-2004, 02:26 PM fieldnum help ...
Average Talker

Posts: 15
Trades: 0
Can you elaborate on the $fieldnum a bit ... does this imply PHP keeps a running count of all forms args that come thru?
new_PHP_er is offline
Reply With Quote
View Public Profile
 
Old 08-10-2004, 02:55 PM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
no, he was just naming it to represent $i.
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Reply     « Reply to Help with PHP form processing
 

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.31516 seconds with 12 queries