Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,321 members, 7,954,290 topics. Date: Friday, 20 September 2024 at 04:06 PM |
Nairaland Forum / Science/Technology / Programming / Help On Php Code Simpllification (1115 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)
Latent Semantic Indexing / Step By Step In Creating Mobile Application / Urgent Help On E-tutor Design
(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. 13 |