[PHP] need form array help

2004-03-01 Thread Brian V Bonini
while ($result = mysql_fetch_array($dbresult_riderlist)) {
print('tr' . \n);
print(tdinput type=\hidden\ name=\rider_id[]\ value=\ .
$result[rider_id] . ' /' . \n);
print(input type=\text\ name=\rider_name[]\ value=\ .
$result[rider_name] . ' size=15 //td' . \n);
print(tdinput type=\text\ name=\rider_license_cat[]\ value=\ .
$result[rider_license_cat] . ' size=3 //td' . \n);
print(tdinput type=\text\ name=\comments[]\ value=\ .
$result[comments] . ' size=20 //td' . \n);
print(tdinput  type=\file\ name=\image[]\ value=\ .
$result[image] . ' size=10 //td' . \n);
print(tdEdit: input type=\radio\ name=\edit_rider_action[]\
value=\edit\ / Delete: input type=\radio\
name=\edit_rider_action[]\ value=\delete\ //td . \n);
print('/tr' . \n);

I'm trying to gather the data from this form and test the condition of
the radio button 'edit_rider_action'.

I can traverse the form data array via $_POST and get the key/value
pairs but am not sure how to test the 'edit_rider_action'.

-- 
Brian V Bonini [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] need form array help

2004-03-01 Thread Chris W. Parker
Brian V Bonini mailto:[EMAIL PROTECTED]
on Monday, March 01, 2004 11:00 AM said:

 while ($result = mysql_fetch_array($dbresult_riderlist)) {
 print('tr' . \n);
 print(tdinput type=\hidden\ name=\rider_id[]\ value=\ .
 $result[rider_id] . ' /' . \n);
 print(input type=\text\ name=\rider_name[]\ value=\ .
 $result[rider_name] . ' size=15 //td' . \n);
 print(tdinput type=\text\ name=\rider_license_cat[]\
 value=\ . $result[rider_license_cat] . ' size=3 //td' .
 \n); print(tdinput type=\text\ name=\comments[]\ value=\ .
 $result[comments] . ' size=20 //td' . \n);
 print(tdinput  type=\file\ name=\image[]\ value=\ .
 $result[image] . ' size=10 //td' . \n);
 print(tdEdit: input type=\radio\ name=\edit_rider_action[]\
 value=\edit\ / Delete: input type=\radio\
 name=\edit_rider_action[]\ value=\delete\ //td . \n);
 print('/tr' . \n);

i think i see some code in that jungle. allow me to clean it up a bit!

while ($result = mysql_fetch_array($dbresult_riderlist)) {
echo QQQ
 tr
  td
   input type=hidden name=rider_id[] value={$result['rider_id']}
/
   input type=text name=rider_name[]
value={$result['rider_name']} size=15 /
  /td
  tdinput type=text name=rider_license_cat[]
value={$result['rider_license_cat']} size=3 //td
  tdinput type=text name=comments[] value={$result['comments']}
size=20 //td
  tdinput type=file name=image[] value={$result['image']}
size=10 //td
  tdEdit: input type=radio name=edit_rider_action[] value=edit
/
   Delete: input type=radio name=edit_rider_action[] value=delete
//td
 /tr

QQQ;
}

 I'm trying to gather the data from this form and test the condition of
 the radio button 'edit_rider_action'.
 
 I can traverse the form data array via $_POST and get the key/value
 pairs but am not sure how to test the 'edit_rider_action'.

well i think since you're doing a radio button you shouldn't have [] on
the end of your field name in the first place. the [] creates a new
element within an array, in your case an array called edit_rider_action.
but because of the way radio buttons work you will never have more than
one value for edit_rider_action so you don't need it turned into an
array after the form is submitted. therefore the following code:

  tdEdit: input type=radio name=edit_rider_action[] value=edit
/
   Delete: input type=radio name=edit_rider_action[] value=delete
//td

should be changed into:

  tdEdit: input type=radio name=edit_rider_action value=edit /
   Delete: input type=radio name=edit_rider_action value=delete
//td

after the form is submitted you can get to the value of
edit_rider_action with: (

?php

$edit_rider_action = $_GET['edit_rider_action'];

?

note: if you submitted your form via post you'll need to use $_POST and
not $_GET.



hth,
chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] need form array help

2004-03-01 Thread Chris W. Parker
Chris W. Parker 
on Monday, March 01, 2004 11:14 AM said:

 i think i see some code in that jungle. allow me to clean it up a bit!
 
 while ($result = mysql_fetch_array($dbresult_riderlist)) {
   echo QQQ
  tr
   td
input type=hidden name=rider_id[]
 value={$result['rider_id']} /
input type=text name=rider_name[]
 value={$result['rider_name']} size=15 /
   /td
   tdinput type=text name=rider_license_cat[]
 value={$result['rider_license_cat']} size=3 //td
   tdinput type=text name=comments[]
 value={$result['comments']} size=20 //td
   tdinput type=file name=image[] value={$result['image']}
 size=10 //td
   tdEdit: input type=radio name=edit_rider_action[]
 value=edit /
Delete: input type=radio name=edit_rider_action[]
 value=delete //td
  /tr
 
 QQQ;
 }

mind the wrap!



c.

p.s. get it? get it?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] need form array help

2004-03-01 Thread Brian V Bonini
On Mon, 2004-03-01 at 14:14, Chris W. Parker wrote:

 
   tdEdit: input type=radio name=edit_rider_action[] value=edit
 /
Delete: input type=radio name=edit_rider_action[] value=delete
 //td
 
 should be changed into:
 
   tdEdit: input type=radio name=edit_rider_action value=edit /
Delete: input type=radio name=edit_rider_action value=delete
 //td
 
 after the form is submitted you can get to the value of
 edit_rider_action with: (
 
 ?php
 
   $edit_rider_action = $_GET['edit_rider_action'];
 
 ?

That make sense except the rendered form is to the effect of:

tr
tdinput type=hidden name=rider_id[] value=1 /
input type=text name=rider_name[] value=Rider 1 size=15 //td
tdinput type=text name=rider_license_cat[] value=1 size=3
//td
tdinput type=text name=comments[] value=comments here size=20
//td
tdinput  type=file name=image[] value= size=10 //td
tdEdit: input type=radio name=edit_rider_action value=edit /
Delete: input type=radio name=edit_rider_action value=delete
//td
/tr
tr
tdinput type=hidden name=rider_id[] value=2 /
input type=text name=rider_name[] value=Rider 2 size=15 //td
tdinput type=text name=rider_license_cat[] value=2 size=3
//td
tdinput type=text name=comments[] value=comments here size=20
//td
tdinput  type=file name=image[] value= size=10 //td
tdEdit: input type=radio name=edit_rider_action value=edit /
Delete: input type=radio name=edit_rider_action value=delete
//td
/tr
tr
tdinput type=hidden name=rider_id[] value=3 /
input type=text name=rider_name[] value=Rider 3 size=15 //td
tdinput type=text name=rider_license_cat[] value=3 size=3
//td
tdinput type=text name=comments[] value=comments here size=20
//td
tdinput  type=file name=image[] value= size=10 //td
tdEdit: input type=radio name=edit_rider_action value=edit /
Delete: input type=radio name=edit_rider_action value=delete
//td
/tr

So I need to test for the state of edit_rider_action in ONE of these and
perform actions based on
it's state. If I do it as above then edit_rider_action is applied to all
rows as in:

while(list($k,$v) = each($rider_id)) {
  echo $k = $vbr /\n;
  echo $edit_rider_action . br /\n;
}

And of course it' entirely possible I'm just being brain dead at the
moment and am thinking about this all wrong.


-- 
Brian V Bonini [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] need form array help

2004-03-01 Thread Chris W. Parker
Brian V Bonini mailto:[EMAIL PROTECTED]
on Monday, March 01, 2004 11:45 AM said:

 That make sense except the rendered form is to the effect of:

[snip]

ok i see... so you want to account for the possibility that each rider
might have a different state? said differently, you don't want all the
riders to have the same edit_rider_action?

in that case i think php turns form elements with [] on the end of them
into regular arrays. example:

?php
$edit_rider_action = $_GET['edit_rider_action'];
?

you then access it just like any other array:

?php
foreach($edit_rider_action as $key = $value)
{
echo $key, $valuebr/\n;
}

$action_cnt = count($edit_rider_action);

for($ictr = 0; $ictr  $action_cnt; $ictr++)
{
echo $ictr, {$edit_rider_action[$ictr]}br/\n;
}
?

does that help?



chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] need form array help

2004-03-01 Thread Brian V Bonini
On Mon, 2004-03-01 at 15:03, Chris W. Parker wrote:

 in that case i think php turns form elements with [] on the end of them
 into regular arrays. example:
 
 ?php
   $edit_rider_action = $_GET['edit_rider_action'];
 ?
 
 you then access it just like any other array:
 
 ?php
   foreach($edit_rider_action as $key = $value)
   {
   echo $key, $valuebr/\n;
   }
 
   $action_cnt = count($edit_rider_action);
 
   for($ictr = 0; $ictr  $action_cnt; $ictr++)
   {
   echo $ictr, {$edit_rider_action[$ictr]}br/\n;
   }
 ?
 
 does that help?


Sort of:

The count for edit_rider_action will always be 1 and it's key/value
needs to mate with one of the rest of the form rows.

For example

Name Class   comments   Action
Rider 1  1   fooedit() delete()
Rider 2  2   baredit() delete()
Rider 3  2   dolar  edit() delete()

Name, Class, and comments are all text fields that can be edited. Only
one of these at a time will be edited or deleted. I just need to
determine which row has Action Selected and then of course WHICH
action. I can get at the data but if you consider something like this:

while(list($k,$v) = each($rider_id)) {
echo $k = $vbr /\n;
while(list($key, $value) = each($edit_rider_action )) {
echo $key = $valuebr /\n;
}
}

the edit_rider_action always has an array index of 0 and I'm not sure
how to associate it with a particular row. Perhaps I can not be cause it
has no unique value in each row. Maybe I need to set an index and
associate it that way as in:

$num_rows = mysql_num_rows($dbresult_riderlist);
$i = 0;

while ($result = mysql_fetch_array($dbresult_riderlist)) {
  Edit: input type=radio name=edit_rider_action[$i] value=edit /
  Delete: input type=radio name=edit_rider_action[$i]
value=delete /

$i++;
}

-- 
Brian V Bonini [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] need form array help

2004-03-01 Thread Kelly Hallman
On 1 Mar 2004, Brian V Bonini wrote:
 while ($result = mysql_fetch_array($dbresult_riderlist)) {
 print('tr' . \n);
 print(tdinput type=\hidden\ name=\rider_id[]\ value=\ .
 $result[rider_id] . ' /' . \n);
 print(input type=\text\ name=\rider_name[]\ value=\ .
 $result[rider_name] . ' size=15 //td' . \n);
 print(tdinput type=\text\ name=\rider_license_cat[]\ value=\ .
 $result[rider_license_cat] . ' size=3 //td' . \n);
 print(tdinput type=\text\ name=\comments[]\ value=\ .
 $result[comments] . ' size=20 //td' . \n);
 print(tdinput  type=\file\ name=\image[]\ value=\ .
 $result[image] . ' size=10 //td' . \n);
 print(tdEdit: input type=\radio\ name=\edit_rider_action[]\
 value=\edit\ / Delete: input type=\radio\
 name=\edit_rider_action[]\ value=\delete\ //td . \n);
 print('/tr' . \n);

Here's one way of doing this:

for($i=0;$i$maxrows;$i++) { // whatever your loop..
echo EOF
div
input type=hidden name=chkrow[] value={$i}
input type=text name=title[{$i}] value={$rowdata[$i]}
...
input type=radio name=mode[{$i}] value=edit
input type=radio name=mode[{$i}] value=delete
/div
EOF;
}

And reading back the form values:
foreach($_REQUEST['chkrow'] as $v) {
$title = $_REQUEST['title'][$v];
$mode = $_REQUEST['mode'][$v]; // 'edit' or 'delete'
}

Adjust to your particular situation...

--Kelly

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php