Help On Php Code Simpllification - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help On Php Code Simpllification (1168 Views)
| Help On Php Code Simpllification by GoodMuyis(op): 7:32pm On Aug 04, 2011 |
Pls look at the cod e below <?PHPPls 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(op): 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(op): 8:10pm On Aug 06, 2011 |
<input type = 'checkbox' name = 'foods[]' value = 'chicken' />ChickenYou 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(op): 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. |
Using Finger Print Scanner On PHP • Help On Php Code For A Dice Game • Free Ebooks On Php Progaming • 2 • 3 • 4
Help • [Project Help Request]: Filesystem search with output in HTML format. • Why Are We Learning Programming Languages
{$score += 1;}
