Stats: 3,189,826 members, 7,938,428 topics. Date: Tuesday, 03 September 2024 at 05:23 AM |
Nairaland Forum / Science/Technology / Programming / Help On Php Code Simpllification (1109 Views)
Using Finger Print Scanner On PHP / Help On Php Code For A Dice Game / Free Ebooks On Php Progaming (2) (3) (4)
Help On Php Code Simpllification by GoodMuyis(m): 7:32pm On Aug 04, 2011 |
Pls look at the cod e below <?PHP Pls is there a way of reducing the code in Bold such that i will just loop thru the html form and get the number of radio buttton with value='yes' which i can use for the value of my $score instead of repeating the if in number of times regards |
Re: Help On Php Code Simpllification by Fayimora(m): 11:26pm On Aug 04, 2011 |
[size=15pt]Yeah you could just use an array instead. So the name of each checkbox/radio shud be somefin like `arrayName[]`[/size] |
Re: Help On Php Code Simpllification by GoodMuyis(m): 3:10pm On Aug 06, 2011 |
Fayimora: pls can you give me sample code ? |
Re: Help On Php Code Simpllification by Fayimora(m): 3:19pm On Aug 06, 2011 |
Ok. sample form. . <input type = 'checkbox' name = 'foods[]' value = 'chicken' />Chicken OR <input type = 'checkbox' name = 'foods[chicken]' value = 'chicken' />Chickendats if you want an associative array. You get your form data by POST and you store $_POST['foods'] into a variable and just loop through it and do/check whatever you want. Give it shot! |
Re: Help On Php Code Simpllification by GoodMuyis(m): 8:10pm On Aug 06, 2011 |
<input type = 'checkbox' name = 'foods[]' value = 'chicken' />Chicken You have forgotten that am using radio button ![]() and i will have something like this Question one: Blaa Bla weeee A: <input type = 'radio' name = 'one' value = 'yes' /> B: <input type = 'radio' name = 'one' value = 'no' /> C: <input type = 'radio' name = 'one' value = 'no' /> up to like 10 Question |
Re: Help On Php Code Simpllification by Fayimora(m): 8:54pm On Aug 06, 2011 |
Well radio/checkbox all the same to me. So ma point still holds. |
Re: Help On Php Code Simpllification by Mobinga: 10:45pm On Aug 06, 2011 |
I suggest you change your 'one' to int 1 so you can loop
Since you want an easy way out. It should work though. ![]() |
Re: Help On Php Code Simpllification by GoodMuyis(m): 10:29am On Aug 08, 2011 |
Thats what i did exactly yesterday and it work out, Thanks for your help |
Re: Help On Php Code Simpllification by Mobinga: 10:32am On Aug 08, 2011 |
It did? Lol. Nice. |
(1) (Reply)
Developing For China Phone / Test Case Generation From UML Diagrams In Java Code / Language And Url In Website
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14 |