moldboy 0 Report post Posted May 30, 2005 I have this tiny problem, that is I have a whole list of vairables, 25 infact, and I'm trying to add them, and store this result in another variable. The problem when I try to call that variable the resulting page justs leaves a blank spot, and the IF array that I have won't change, it just goes for the first choice.Is this wrong? $var1+$var2+..........$var24+$var25 = $vartotal; bearing in mind that there is more in the middle I just didn't feel like typing it! Share this post Link to post Share on other sites
Tyssen 0 Report post Posted May 30, 2005 Try $vartotal = $var1 + $var2 .... ; Share this post Link to post Share on other sites
HmmZ 0 Report post Posted May 30, 2005 like Tyssen said, you're doing it the wrong way. always start with the new variable that you are settingso $vartotal=$var1+$var2but if you are gonna use if arrays you should do:array($vartotal)=$var1+$var2i think Share this post Link to post Share on other sites
moldboy 0 Report post Posted May 30, 2005 Thanks to you both, I don't think I am using an array. Anyhow I have uped your rep. So while we are wiating, how could I take this total and say all the numbers that fall between say 1-10 do this, and all the numbers between 11-20 result in something else? Share this post Link to post Share on other sites
Tyssen 0 Report post Posted May 30, 2005 Thanks to you both, I don't think I am using an array. Anyhow I have uped your rep. So while we are wiating, how could I take this total and say all the numbers that fall between say 1-10 do this, and all the numbers between 11-20 result in something else?If you're talking about consecutive numbers, you could use a loop.<?php$j = 0;for ($i=1; $i<=10; $i++){$j = $j + $i;}echo $j;?>or<?php$j = 0;for ($i=11; $i<=20; $i++){$j = $j + $i;}echo $j;?> Share this post Link to post Share on other sites
moldboy 0 Report post Posted May 31, 2005 Thanks for your reply, but I started to mess around, and first tryed: IF (3 < $var < 5)Which would mean true if $var is 4. But that didn't work, so I tryedIF (($var > 3) && ($var < 5))Which works, so if anyone wants to see the result:http://forums.xisto.com/no_longer_exists/Let me know what you think. Share this post Link to post Share on other sites
Tyssen 0 Report post Posted May 31, 2005 Well it looks like it all works properly. Nice job. Just one small thing though: this is how you spell congratulations. Share this post Link to post Share on other sites
moldboy 0 Report post Posted May 31, 2005 LOL If you go to the Questions you may notice that I can't spell community (cimmunity) either! Share this post Link to post Share on other sites
HmmZ 0 Report post Posted May 31, 2005 you're making it harder then it is moldboy, a quiz with radio buttons is easy to setup, if you know how to do it, here it is:  These are the first 2 questions note: the radio names are setup like this: question 1, answer 1=11 <?php$score="0";?><form action=simpprocess_gui.php method=post>Simpsons Trivia Challenge!<br><input type=text name=challenger value="Name">1. What device does Dr. Hibert use to get the glued on gag pieces from Bart's face? <br><input type=radio name=11>Shotgun<br><input type=radio name=12>Button Applicator<br><input type=radio name=13>Fly Swatter<br><input type=radio name=14>Tetanus Shot<br><br> 2. According to Grandpa, what phrases origins are long and rambling? <br><input type=radio name=21>It Takes Two to Tango<br><input type=radio name=22>Don't have a cow man!<br><input type=radio name=23>Long story short<br><input type=radio name=24>At the end of the day<br>After that it's easy to add to the score:note: i could not get the right answer from question 1 (all answers results in 0points out of 25..) so let's say answer 1 was the right answer. for both questions.. for($11){ $score++ }for($21){ $score++ }//... going from $11 to $251<input type=hidden value=$score name=score><input type=submit value='submit' name=submit>simpprocess_gui.phpnote: this is only part of the page $total="25";$score=$_GET['score'];if(($score<=0) && ($score<=5)){$title="Ralph Wiggum"; }if(($score>5) && ($score<=10)){$title=".."; }if(($score>10) && ($score<=15)){$title=".."; }if(($score>15) && ($score<=20)){$title=".."; }if(($score>20) && ($score<=25)){$title=".."; }$name=$_POST['challenger'];print "Congratulations  $name, you scored [b]$score[/b] out of [b]$total[/b].<br>";print "This gives you the intelligence of [b]$title[/b]!"; Hope this helps you Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 1, 2005 SO I have a few things to say to that. First, why did you start at 11, not 01, for the answers. Also, I apprecieate the help, but I'm just learning, and haven't used the FOR command much, that Idea didn't occour to me.And when you say: note: i could not get the right answer from question 1 (all answers results in 0points out of 25..) so let's say answer 1 was the right answer. for both questions..what exactly are you saying?Because I can get 25 out of 25, when I do the quiz. Share this post Link to post Share on other sites
HmmZ 0 Report post Posted June 1, 2005 well i tried all answers on question 1, to see wich answer was right and process it in the script, but either 1 of the answers to question 1 gave me 0points out of 25, are you supposed to do the whole quiz to get points?and why i used 11 instead of 01, as explained in my note, question 1, answer 1=11, but you can use 01 if you want..The script i made for you is just a version that you can learn from (like the for() statement) and it's also something i like to do to learn it to myself, learn through practise is my motto Share this post Link to post Share on other sites
moldboy 0 Report post Posted June 1, 2005 I have made no attempt to require all answers, unless the way I wrote something made that statement. I think it may be a bug as today I experienced a result of 23 out of 25, and there were three wrong answers. learn through practiseI could not aggree more, I have tried learning Java, and Javascipt, from a book, the problem is, what I know I can't do because there is script preperation, and stuff. You need to lean infron of a computer, like learn to drive from a book, can't be done well, you gotta hit some things, that way you have experience Share this post Link to post Share on other sites