[PHP] update mysql using radio button

2004-06-01 Thread Matt Newell

hello all -

i'm having a problem getting an UPDATE to work with radio buttons and
i'm not sure where it's gone wrong. the initial values are being grabbed
properly, but unfortunately they don't want to get updated. the regular
text form values update just fine. would appreciate some help.

the html:

input type=hidden name=id value=?php echo $id ?

club member?br
No: input type=radio name=club_member ?php if($row-club_member ==
'N'){echo 'CHECKED';}?br
Yes: input type=radio name=club_member ?php if($row-club_member
== 'Y'){echo 'CHECKED';}?


the query to update:

$query = UPDATE outdoor SET name='$name', email='$email', zip='$zip',
club_member='$club_member' WHERE id='$id';
$result = mysql_query($query) or die (Error in query: $query.  .
mysql_error());



[trying to keep the code paste to what i think is important, let me know
if more is needed for info.]


thanks!
m.

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



RE: [PHP] update mysql using radio button

2004-06-01 Thread Jay Blanchard
[snip]
i'm having a problem getting an UPDATE to work with radio buttons and
i'm not sure where it's gone wrong. the initial values are being grabbed
properly, but unfortunately they don't want to get updated. the regular
text form values update just fine. would appreciate some help.

the html:

input type=hidden name=id value=?php echo $id ?

club member?br
No: input type=radio name=club_member ?php if($row-club_member ==
'N'){echo 'CHECKED';}?br
Yes: input type=radio name=club_member ?php if($row-club_member
== 'Y'){echo 'CHECKED';}?
[/snip]

You have to create a value for the box...or check for ON

function radioBox($radioBoxState){
/*
** this function will get the tail value of the checked radio
button
** and return the appropriate value for use by the database,
either a
** 'y' or 'n'
*/
if(TRUE == preg_match('/Yes/', $radioBoxState)){
$radioBoxState = y;
} elseif(TRUE == preg_match('/No/', $radioBoxState)){
$radioBoxState = n;
}
return $radioBoxState;
}
function checkBox($checkBoxState){
/* 
** this is a function that will turn an 'on' checkbox into a 'y'
for the database
** if it is not 'on' an 'n' will be returned
*/
if(on == $checkBoxState){
$checkBoxData = y;
} else {
$checkBoxData = n;
}
return $checkBoxData;

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



Re: [PHP] update mysql using radio button

2004-06-01 Thread Daniel Clark
I think you need Values for the radio buttons.

input type=radio name=club_member Value=N ?php if($row-club_member
 ='N'){echo 'CHECKED';}?


 hello all -

 i'm having a problem getting an UPDATE to work with radio buttons and
 i'm not sure where it's gone wrong. the initial values are being grabbed
 properly, but unfortunately they don't want to get updated. the regular
 text form values update just fine. would appreciate some help.

 the html:

 input type=hidden name=id value=?php echo $id ?

 club member?br
 No: input type=radio name=club_member ?php if($row-club_member
 ='N'){echo 'CHECKED';}?br
 Yes: input type=radio name=club_member ?php if($row-club_member
 == 'Y'){echo 'CHECKED';}?


 the query to update:

 $query = UPDATE outdoor SET name='$name', email='$email', zip='$zip',
 club_member='$club_member' WHERE id='$id';
 $result = mysql_query($query) or die (Error in query: $query.  .
 mysql_error());



 [trying to keep the code paste to what i think is important, let me know
 if more is needed for info.]


 thanks!
 m.

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



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



RE: [PHP] update mysql using radio button

2004-06-01 Thread Matt Newell

how embarrassing. :] yes, of course that would be the problem.

just to note, i'm enjoying learning php/mysql and appreciate the help
from this list. it's a great community and the good will makes it a
great place to ask the sometimes really stupid questions.

best,
m.


-Original Message-
From: Daniel Clark [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 01, 2004 1:14 PM
To: Matt Newell
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] update mysql using radio button

I think you need Values for the radio buttons.

input type=radio name=club_member Value=N ?php
if($row-club_member  ='N'){echo 'CHECKED';}?


 hello all -

 i'm having a problem getting an UPDATE to work with radio buttons and 
 i'm not sure where it's gone wrong. the initial values are being 
 grabbed properly, but unfortunately they don't want to get updated. 
 the regular text form values update just fine. would appreciate some
help.

 the html:

 input type=hidden name=id value=?php echo $id ?

 club member?br
 No: input type=radio name=club_member ?php if($row-club_member 
 ='N'){echo 'CHECKED';}?br
 Yes: input type=radio name=club_member ?php if($row-club_member

 == 'Y'){echo 'CHECKED';}?


 the query to update:

 $query = UPDATE outdoor SET name='$name', email='$email', zip='$zip',

 club_member='$club_member' WHERE id='$id'; $result = 
 mysql_query($query) or die (Error in query: $query.  .
 mysql_error());



 [trying to keep the code paste to what i think is important, let me 
 know if more is needed for info.]


 thanks!
 m.

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



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



Re: [PHP] update mysql using radio button

2004-06-01 Thread John W. Holmes
From: Daniel Clark [EMAIL PROTECTED]

 input type=radio name=club_member Value=N ?php
if($row-club_member
  ='N'){echo 'CHECKED';}?

=='N', you mean. :)

---John Holmes...

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



Re: [PHP] update mysql using radio button

2004-06-01 Thread Daniel Clark
Right.  (oops)

 From: Daniel Clark [EMAIL PROTECTED]

 input type=radio name=club_member Value=N ?php
 if($row-club_member
  ='N'){echo 'CHECKED';}?

 =='N', you mean. :)

 ---John Holmes...

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