RE: [PHP] Radio buttons problem
Unless, of course, what you have is name[], email[], sex[0] name[], email[], sex[1] name[], email[], sex[2] Yep, that's exactly what I have. If it's important to you that the indexes match across name[], email[] and sex[], then you must supply them explicitly for every field in the group I guess there's no other way than this, so OK I'll do it. Thanks. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24912487.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the resulting array with foreach, and there's no problem. There is, the entries are grouped by its index. So, I group name[0], email[0], and sex[0] as one. The problem if I don't maintain the index for radio buttons, the index could go wrong. In the previous example I gave, if entry2 is deleted (and I don't maintain the index) then entry3 will contain name[1], email[1], and sex[2] which isn't desirable. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24897287.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
-Original Message- From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] Sent: 10 August 2009 11:11 To: php-general@lists.php.net Subject: RE: [PHP] Radio buttons problem Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the resulting array with foreach, and there's no problem. There is, the entries are grouped by its index. So, I group name[0], email[0], and sex[0] as one. The problem if I don't maintain the index for radio buttons, the index could go wrong. In the previous example I gave, if entry2 is deleted (and I don't maintain the index) then entry3 will contain name[1], email[1], and sex[2] which isn't desirable. Huh??? If you have entries for: name[0], email[0], sex[0] name[1], email[1], sex[1] name[2], email[2], sex[2] ... and then delete the entry containing sex[1], why wouldn't you just end up with name[0], email[0], sex[0] name[2], email[2], sex[2] ... ??? Unless, of course, what you have is name[], email[], sex[0] name[], email[], sex[1] name[], email[], sex[2] ... ... in which case, don't do that! If it's important to you that the indexes match across name[], email[] and sex[], then you must supply them explicitly for every field in the group -- if you name some of the fields with [], and some with explicit [1], [2] indexes, you're setting yourself up for exactly this kind of mismatch problem when you come to delete (or insert!) entries. Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
-Original Message- From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] Sent: 10 August 2009 11:11 To: php-general@lists.php.net Subject: RE: [PHP] Radio buttons problem There is, the entries are grouped by its index. So, I group name[0], email[0], and sex[0] as one. The problem if I don't maintain the index for radio buttons, the index could go wrong. This is far more complicated than it needs to be. Check this out: http://php1.net/b/form-radio/ In addition to 'option[]', I certainly can add additional radio groups for name[], email[], and sex[]. The solution is -- DO NOT force adding an index to each array, such as name[0], email[0], sex[0], but rather let it be name[], email[], and sex[]. If you try it, it will work. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
you will have to manually maintain the number in the bracket. but you can try using a template engine like smarty, and use a for loop to take care of the numbers in the brackets Well.. the entries are inserted / deleted dynamically using JavaScript (to avoid unnecessary refresh). Why can't it be a multidimensional array? something like sex[][], first bracket denotes for which entry this field is, second is for which choice is chosen. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24859548.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
you dont seem to understand how radio buttons work. they treat name=sex[][] as a single group. and you can select only one element in that group. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Radio buttons problem
-Original Message- From: leledumbo [mailto:leledumbo_c...@yahoo.co.id] Sent: 07 August 2009 05:43 This should work: input type='radio' name='sex[1]' value='1' input type='radio' name='sex[1]' value='2' input type='radio' name='sex[2]' value='1' input type='radio' name='sex[2]' value='2' Yes, that works. But should I manually maintain the number in the bracket? Is there anyway so that it can be automatically maintained? Because my app allows to delete entries arbitrarily. For instance, consider this layout (+ is insert button, - is delete): entry1 +/- entry2 +/- entry3 +/- entry1 has sex[0] field, entry2 has sex[1] and so on. If entry2 is deleted, then I have to change all sex fields in entries below entry2 which is a waste of time. Why do you? There's no reason you *have* to have consecutive indexes -- just iterate over the resulting array with foreach, and there's no problem. (Unless your back-end logic demands sequential id numbers, but my opinion would be there's something wrong with your design if it does.) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
This should work: input type='radio' name='sex[1]' value='1' input type='radio' name='sex[1]' value='2' input type='radio' name='sex[2]' value='1' input type='radio' name='sex[2]' value='2' Yes, that works. But should I manually maintain the number in the bracket? Is there anyway so that it can be automatically maintained? Because my app allows to delete entries arbitrarily. For instance, consider this layout (+ is insert button, - is delete): entry1 +/- entry2 +/- entry3 +/- entry1 has sex[0] field, entry2 has sex[1] and so on. If entry2 is deleted, then I have to change all sex fields in entries below entry2 which is a waste of time. -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24858699.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
you will have to manually maintain the number in the bracket. but you can try using a template engine like smarty, and use a for loop to take care of the numbers in the brackets -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Radio buttons problem
I'm creating a form with variable number of entries (user controlled) where each entry consists of some input fields. For most input types, appending [] to their names is enough to allow me processing each entry. So, for instance, if there are 3 entries with field name[] and email[], they can be accessed as: name = Array( 0 = 'name1', 1 = 'name2', 2 = 'name3' ) email = Array( 0 = 'email1', 1 = 'email2', 2 = 'email3' ) However, this isn't the case for radio buttons. Let's see a common usage: sex determinition. Using sex[] will make the one in an entry to behave dependently to another. This is due to the radio button behavior to group choices based on name. How can I make a radio button in one entry to behave independently from the one in another so that it can be accessed as name and email above? -- View this message in context: http://www.nabble.com/Radio-buttons-problem-tp24786766p24786766.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Radio buttons problem
On Mon, 03 Aug 2009 11:01:13 +0300, leledumbo leledumbo_c...@yahoo.co.id wrote: How can I make a radio button in one entry to behave independently from the one in another so that it can be accessed as name and email above? This should work: input type='radio' name='sex[1]' value='1' input type='radio' name='sex[1]' value='2' input type='radio' name='sex[2]' value='1' input type='radio' name='sex[2]' value='2' -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] radio buttons in $_POST
I have this form.html: form method=post action=form.php text input input type=text name=input_testbr / radio input1 input type=radio name=radio_test value=test1 / radio input2 input type=radio name=radio_test value=test2 / input type=submit value=Submit /form Then I have this script (form.php): ?php foreach ($_POST as $key = $val) echo $key = $val\n; ? If I simply submit the form empty, all I get back from the script is the text input $key. The radio button doesn't show up. Why is that and how can I have it show up? (the radio input does show up once one of the radios is checked, but I need it to show up when empty as well.) -- H | I haven't lost my mind; it's backed up on tape somewhere. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons in $_POST
Hi, You solve the problem yourself: the radio input does show up once one of the radios is checked. When it is unchecked is isn't set...if you need to assign it a value in any circumstances you should test it with ?php $chkbox1 = (isset($_POST[radio_test])) ? true : false; ? for example (of course you may omit the ternary operator...isset() will do the same). Ashley M. Kirchner wrote: I have this form.html: form method=post action=form.php text input input type=text name=input_testbr / radio input1 input type=radio name=radio_test value=test1 / radio input2 input type=radio name=radio_test value=test2 / input type=submit value=Submit /form Then I have this script (form.php): ?php foreach ($_POST as $key = $val) echo $key = $val\n; ? If I simply submit the form empty, all I get back from the script is the text input $key. The radio button doesn't show up. Why is that and how can I have it show up? (the radio input does show up once one of the radios is checked, but I need it to show up when empty as well.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons in $_POST
That's because Radio Buttons and Check Boxes do not return anything if not checked or selected. So you gotta explicitly do it ur self. That is u gotta check for it's validity and non-empiness. e.g. in ur scenario if(!isset($_POST['radio_test'])) { //print out all the options unselected } else { // print the value and show the rest empty in the report } On 4/23/05, Ashley M. Kirchner [EMAIL PROTECTED] wrote: I have this form.html: form method=post action=form.php text input input type=text name=input_testbr / radio input1 input type=radio name=radio_test value=test1 / radio input2 input type=radio name=radio_test value=test2 / input type=submit value=Submit /form Then I have this script (form.php): ?php foreach ($_POST as $key = $val) echo $key = $val\n; ? If I simply submit the form empty, all I get back from the script is the text input $key. The radio button doesn't show up. Why is that and how can I have it show up? (the radio input does show up once one of the radios is checked, but I need it to show up when empty as well.) -- H | I haven't lost my mind; it's backed up on tape somewhere. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . . . Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- M.Saleh.E.G 97150-4779817
Re: [PHP] radio buttons in $_POST
Ashley M. Kirchner wrote: I have this form.html: form method=post action=form.php text input input type=text name=input_testbr / radio input1 input type=radio name=radio_test value=test1 / radio input2 input type=radio name=radio_test value=test2 / input type=submit value=Submit /form Then I have this script (form.php): ?php foreach ($_POST as $key = $val) echo $key = $val\n; ? If I simply submit the form empty, all I get back from the script is the text input $key. The radio button doesn't show up. Why is that and how can I have it show up? (the radio input does show up once one of the radios is checked, but I need it to show up when empty as well.) One way would be to have a selection None and have it selected by default. As in, None input type=radio checked name=radio_test value=None / Or you can just do something like, ?php if(!isset[$_POST['radio_test'])) echo radio_test = none\n; foreach ($_POST as $key = $val) echo $key = $val\n; ? Janet -- Janet Valade -- janet.valade.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons in $_POST
None input type=radio checked name=radio_test value=None / And if you didn't want it to show to the user (because they have to make a choice anyway) . . . you can use this css: input[value=None] { display: none; } You should then always have a value to play with in PHP, and the user doesn't see any extra clutter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons in $_POST
Justin Gruenberg wrote: None input type=radio checked name=radio_test value=None / And if you didn't want it to show to the user (because they have to make a choice anyway) . . . you can use this css: input[value=None] { display: none; } You should then always have a value to play with in PHP, and the user doesn't see any extra clutter. which unfortunately currently only works in a couple of browsers (mozilla, (and thus firefox), and opera I think (?)) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] radio buttons checked or not
hi... i have this code: ?if($old['Type']==Annual){? input type=radio name=eventtype value=Annualchecked accesskey=yYes ?}else {? input type=radio name=eventtype value=OneTime checked accesskey=nNo?}? was just wondering if that was the right way to determine the state of a radio button...? if the value of $old['Type']=Annual then the yes button is checked...if not then the no button is checked instead... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] radio buttons checked or not
[snip] i have this code: ?if($old['Type']==Annual){? input type=radio name=eventtype value=Annualchecked accesskey=yYes ?}else {? input type=radio name=eventtype value=OneTime checked accesskey=nNo?}? was just wondering if that was the right way to determine the state of a radio button...? if the value of $old['Type']=Annual then the yes button is checked...if not then the no button is checked instead... [/snip] Check for the value assigned to each if(Annual == $_POST['eventtype']){ ... do stuff ... } elseif(OneTime == $_POST['eventtype']){ ... do other stuff ... } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons checked or not
From: Andy B [EMAIL PROTECTED] i have this code: ?if($old['Type']==Annual){? input type=radio name=eventtype value=Annualchecked accesskey=yYes ?}else {? input type=radio name=eventtype value=OneTime checked accesskey=nNo?}? was just wondering if that was the right way to determine the state of a radio button...? if the value of $old['Type']=Annual then the yes button is checked...if not then the no button is checked instead... Assuming $old['Type'] somehow comes from $_REQUEST['eventtype'] (or is related to it), then yeah, that'll work. Another way: $checked[$old['Type']] = ' checked'; echo input type=\radio\ name=\eventtype\ value=\Annual\ {$checked['Annual']}Yes; echo input type=\radio\ name=\eventtype\ value=\OneTime\ {$checked['OneTime']}No; This method works even better when you have an array('Annual' = 'Yes', 'OneTime' = 'No') that you use to build the checkboxes. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons checked or not
Assuming $old['Type'] somehow comes from $_REQUEST['eventtype'] (or is related to it), then yeah, that'll work. no its coming from a db result from fetch_array() of which im having an interesting problem with right now but thats in another post -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons checked or not
My understanding is if the variable exists then the radio button was checked. i have this code: ?if($old['Type']==Annual){? input type=radio name=eventtype value=Annualchecked accesskey=yYes ?}else {? input type=radio name=eventtype value=OneTime checked accesskey=nNo?}? was just wondering if that was the right way to determine the state of a radio button...? if the value of $old['Type']=Annual then the yes button is checked...if not then the no button is checked instead... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons checked or not
- Original Message - From: Daniel Clark [EMAIL PROTECTED] To: Andy B [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 4:22 PM Subject: Re: [PHP] radio buttons checked or not My understanding is if the variable exists then the radio button was checked. i have this code: ?if($old['Type']==Annual){? input type=radio name=eventtype value=Annualchecked accesskey=yYes ?}else {? input type=radio name=eventtype value=OneTime checked accesskey=nNo?}? was just wondering if that was the right way to determine the state of a radio button...? if the value of $old['Type']=Annual then the yes button is checked...if not then the no button is checked instead... nope..its pulled out of a db... its a field name called Type and its ENUM ('Annual', 'OneTime') and i have to load all of the record back into the form so it can be changed and put back into the table -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons
he wants 3 radio buttons on a form .. something to the affect of: input type=radio name=general value=this is a general statement?this is a general post input type=radio name=urgent value=this is an urgent messagethis is an urgent post input type=radio name=concern value=this is bothering methis is a message i need to post because it bothers me would this be the right setup for radio buttons and if so what is the best way to tell what one of them is checked without using lots of if else statements or is that unavoidable? or is there even a better way to set up radio buttons altogether... i havent worked with radio buttons all that much and dont know that much about them as far as php goes... You should check out libHtmlForm at http://nirvani.org/software/libHtmlForm/ Cheers, Gonzo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] radio buttons
oh sorry i forgot in the last message too.. he wants 3 radio buttons on a form .. something to the affect of: input type=radio name=general value=this is a general statement?this is a general post input type=radio name=urgent value=this is an urgent messagethis is an urgent post input type=radio name=concern value=this is bothering methis is a message i need to post because it bothers me would this be the right setup for radio buttons and if so what is the best way to tell what one of them is checked without using lots of if else statements or is that unavoidable? or is there even a better way to set up radio buttons altogether... i havent worked with radio buttons all that much and dont know that much about them as far as php goes... --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] radio buttons
Using a case statment would be the easyest way to tell which one was checked, but technicly one could check all three unless the value of name is changed the same like ... input type=radio name=priority value=this is a general statement?this is a general post input type=radio name=priority value=this is an urgent messagethis is an urgent post input type=radio name=priority value=this is bothering methis is a message i need to post because it bothers me -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED] Sent: Monday, February 24, 2003 1:30 AM To: [EMAIL PROTECTED] Subject: [PHP] radio buttons oh sorry i forgot in the last message too.. he wants 3 radio buttons on a form .. something to the affect of: input type=radio name=general value=this is a general statement?this is a general post input type=radio name=urgent value=this is an urgent messagethis is an urgent post input type=radio name=concern value=this is bothering methis is a message i need to post because it bothers me would this be the right setup for radio buttons and if so what is the best way to tell what one of them is checked without using lots of if else statements or is that unavoidable? or is there even a better way to set up radio buttons altogether... i havent worked with radio buttons all that much and dont know that much about them as far as php goes... --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/11/2003 -- 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] radio buttons
so if the name of radio is priority then it needs not be checked for its value other than it being empty? or could i say put that one of those is defaulted to checked... input type=radio value=this is a general post? checkedthis is a general post . then do in the php script something like: ?php if(!empty($priority)) { insert into table values(NULL, '$name', '$post', '$priority'))||die(mysql_error()); else { ? html head titleThere was an error in your form submission/title /head body there was an error in your submitted form: you didnt choose a message priority. a href=postprayer.htmclick here/a to go back to the form to re-enter your post. /body /html ?php } //finnish script here.. ? - Original Message - From: Dennis Cole [EMAIL PROTECTED] To: Sunfire [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 24, 2003 1:29 AM Subject: RE: [PHP] radio buttons Using a case statment would be the easyest way to tell which one was checked, but technicly one could check all three unless the value of name is changed the same like ... input type=radio name=priority value=this is a general statement?this is a general post input type=radio name=priority value=this is an urgent messagethis is an urgent post input type=radio name=priority value=this is bothering methis is a message i need to post because it bothers me -Original Message- From: Sunfire [mailto:[EMAIL PROTECTED] Sent: Monday, February 24, 2003 1:30 AM To: [EMAIL PROTECTED] Subject: [PHP] radio buttons oh sorry i forgot in the last message too.. he wants 3 radio buttons on a form .. something to the affect of: input type=radio name=general value=this is a general statement?this is a general post input type=radio name=urgent value=this is an urgent messagethis is an urgent post input type=radio name=concern value=this is bothering methis is a message i need to post because it bothers me would this be the right setup for radio buttons and if so what is the best way to tell what one of them is checked without using lots of if else statements or is that unavoidable? or is there even a better way to set up radio buttons altogether... i havent worked with radio buttons all that much and dont know that much about them as far as php goes... --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 1/11/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] radio buttons from MySQL query?
How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] radio buttons from MySQL query?
I don't think so, Put the bracket with your radio's name not with your the value/// For example : print td width=2input type=radio name=gl_acct[] value=$row['acct']{$row['acct']}/td ... and so one/ - Original Message - From: David Jackson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query? How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- 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] radio buttons from MySQL query?
There is no reason to put brackets behind the name of the radio element. The brackets are neccessary for multi-select elements like checkboxes, but radio buttone are a single select element. Your if statement should be a while loop. I'm sure you don't want to set this ( value=acct[] ) as the value for each radio button. Do it that way, and no matter which one is picked, it will be the same value. rija wrote: I don't think so, Put the bracket with your radio's name not with your the value/// For example : print td width=2input type=radio name=gl_acct[] value=$row['acct']{$row['acct']}/td ... and so one/ - Original Message - From: David Jackson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query? How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- 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] radio buttons from MySQL query?
oups ... you're right ! - Original Message - From: John Nichel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php [EMAIL PROTECTED]; David Jackson [EMAIL PROTECTED] Sent: Monday, November 04, 2002 2:57 PM Subject: Re: [PHP] radio buttons from MySQL query? There is no reason to put brackets behind the name of the radio element. The brackets are neccessary for multi-select elements like checkboxes, but radio buttone are a single select element. Your if statement should be a while loop. I'm sure you don't want to set this ( value=acct[] ) as the value for each radio button. Do it that way, and no matter which one is picked, it will be the same value. rija wrote: I don't think so, Put the bracket with your radio's name not with your the value/// For example : print td width=2input type=radio name=gl_acct[] value=$row['acct']{$row['acct']}/td ... and so one/ - Original Message - From: David Jackson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query? How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- 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] radio buttons from MySQL query?
OK, this works but there has to be a pretty way? John, I'm not sure what you mean about the while loop? David - Works - html headtitleOperation Sticky Bun/title/head body h3 align=centerOperation Sticky Bun /h3 ?php require('connect.php'); ? ?php print 'form action=hello.php method=post'; $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print 'input type=radio name=ledger_acct value='; print $row[acct];print ''; print $row[descript];print 'br'; } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} print '/form'; ? /body /html Rija wrote: oups ... you're right ! - Original Message - From: John Nichel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php [EMAIL PROTECTED]; David Jackson [EMAIL PROTECTED] Sent: Monday, November 04, 2002 2:57 PM Subject: Re: [PHP] radio buttons from MySQL query? There is no reason to put brackets behind the name of the radio element. The brackets are neccessary for multi-select elements like checkboxes, but radio buttone are a single select element. Your if statement should be a while loop. I'm sure you don't want to set this ( value=acct[] ) as the value for each radio button. Do it that way, and no matter which one is picked, it will be the same value. rija wrote: I don't think so, Put the bracket with your radio's name not with your the value/// For example : print td width=2input type=radio name=gl_acct[] value=$row['acct']{$row['acct']}/td ... and so one/ - Original Message - From: David Jackson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query? How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- 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] radio buttons from MySQL query?
Belay that. I didn't notice the do / while loop inside of the if statement. I don't know if this is prettier, but I would echo out the radio button in one line echo ( input type=\radio\ name=\ledger_acct\ value=\ . $row[acct] . \ . $row[descript] . br\n; David Jackson wrote: OK, this works but there has to be a pretty way? John, I'm not sure what you mean about the while loop? David - Works - html headtitleOperation Sticky Bun/title/head body h3 align=centerOperation Sticky Bun /h3 ?php require('connect.php'); ? ?php print 'form action=hello.php method=post'; $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print 'input type=radio name=ledger_acct value='; print $row[acct];print ''; print $row[descript];print 'br'; } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} print '/form'; ? /body /html Rija wrote: oups ... you're right ! - Original Message - From: John Nichel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: php [EMAIL PROTECTED]; David Jackson [EMAIL PROTECTED] Sent: Monday, November 04, 2002 2:57 PM Subject: Re: [PHP] radio buttons from MySQL query? There is no reason to put brackets behind the name of the radio element. The brackets are neccessary for multi-select elements like checkboxes, but radio buttone are a single select element. Your if statement should be a while loop. I'm sure you don't want to set this ( value=acct[] ) as the value for each radio button. Do it that way, and no matter which one is picked, it will be the same value. rija wrote: I don't think so, Put the bracket with your radio's name not with your the value/// For example : print td width=2input type=radio name=gl_acct[] value=$row['acct']{$row['acct']}/td ... and so one/ - Original Message - From: David Jackson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 1:15 PM Subject: [PHP] radio buttons from MySQL query? How do I go about building radio buttons using the results of a MySQL query. The record layout looks like this: acct cat description I want to use acct as the value=acct in the input statement for the radio box. The code below almost works? TIA, David ?php $header = mysql_query (SELECT * FROM chart ORDER BY acct ); if ($row = mysql_fetch_array($header)) { do { print(tr bgcolor=\white\ ); print 'td width=5input type=radio name=gl_acct value=acct[]/td'; print(td width=\12\); print $row[acct]; print /tdtd width=\12\; print $row[cat]; print /tdtd ; print $row[descript]; print(/td/tr\n); } while($row = mysql_fetch_array($header)); } else {print Sorry, no records were found!;} ? -- 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] radio buttons
Just a hunch... but try value=1ndash;24 and see how that works, so basically substitute - for ndash; I can't see the rest of your code and what else you might be appending to $msgtxt, so it could be something else... Yes it was something else. I did a wrong comparison with the variable: $empleados= in stead of $empleados==. So it was set to be an empty string. Still doesn't explain the 0 though, but anyhow, it works now -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] radio buttons
Actually it does explain it, you set the variable to false, which of course is 0, so that's why you had a 0 :) Also a good way of seeing if the variable is set, no equaling 0, , , false, etc is by using the empty function if (empty($empleados)) Glad you figured it out though! Cheers Rick Just a hunch... but try value=1ndash;24 and see how that works, so basically substitute - for ndash; I can't see the rest of your code and what else you might be appending to $msgtxt, so it could be something else... Yes it was something else. I did a wrong comparison with the variable: $empleados= in stead of $empleados==. So it was set to be an empty string. Still doesn't explain the 0 though, but anyhow, it works now -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]