Sum - Adding things

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #11) by moldboy on Jun 1 2005, 11:14 PM. (Line Breaks Removed)
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. QUOTElearn 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, ... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Sum - Adding things

moldboy
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?
CODE
$var1+$var2+..........$var24+$var25 = $vartotal;


bearing in mind that there is more in the middle I just didn't feel like typing it!

Reply

Tyssen
Try $vartotal = $var1 + $var2 .... ;

Reply

HmmZ
like Tyssen said, you're doing it the wrong way. always start with the new variable that you are setting

so $vartotal=$var1+$var2

but if you are gonna use if arrays you should do:
array($vartotal)=$var1+$var2

i think huh.gif

Reply

moldboy
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?

Reply

Tyssen
QUOTE(moldboy @ May 31 2005, 07:45 AM)
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.

CODE
<?php
$j = 0;
for ($i=1; $i<=10; $i++)
{
$j = $j + $i;
}
echo $j;
?>

or
CODE
<?php
$j = 0;
for ($i=11; $i<=20; $i++)
{
$j = $j + $i;
}
echo $j;
?>

 

 

 


Reply

moldboy
Thanks for your reply, but I started to mess around, and first tryed:
CODE
IF (3 < $var < 5)

Which would mean true if $var is 4. But that didn't work, so I tryed
CODE
IF (($var > 3) && ($var < 5))

Which works, so if anyone wants to see the result:
http://d-gression.trap17.com/fun/simpquiz_gui.html
Let me know what you think.

Reply

Tyssen
Well it looks like it all works properly. Nice job. Just one small thing though: this is how you spell congratulations. wink.gif

Reply

moldboy
LOL If you go to the Questions you may notice that I can't spell community (cimmunity) either! tongue.gif

Reply

HmmZ
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
CODE

<?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..
CODE

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.php
note: this is only part of the page
CODE

$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

Reply

moldboy
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:
QUOTE
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.

Reply

Latest Entries

moldboy
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.
QUOTE
learn through practise

I 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 tongue.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Similar Topics

Keywords : sum, adding, things

  1. Archive.org The Public Domain And Basic Copyright
    Archive.org is a great place to download old movies and things. (1)
  2. Destination Address For "submit" Button
    Adding a destination email address to a "Submit" button (5)
    I discovered this site while searching for an answer on what HTML code to use to print a web page.
    "Skymonkey" provided the answer to a similar question posed back in 2005. I now have another
    question about submitting a web page with fill in blanks. Is there an easy HTML code that can
    include a destination address to a "Submit" button without having to use Javascript? I have created
    a form with fill in blanks and now want to have people simply hit the Submit button to send their
    information to a particular email address. Thanks for any help. Tom T.....
  3. Things To Know About Dreams
    Symbols, dream phonomenons, symbolic characters, kinds of dreams, colo (1)
    First, I was soooo happy to find that there was a spirituality forum! I have a looooot to share
    in this field >:D Second, English is not my first language so there will probably be errors in what
    I write and maybe a lot of misused words since I have never wrote about this subject in English. So
    please, if you find such errors, tell me so I can correct them. (: Everything I'm going to
    share here is based on Carl Gustav Jung's works and studies. This will help you a lot to analyse
    your dreams /smile.gif" style="vertical-align:middle" emoid=":)" border="0" al....
  4. Why Are We Dreaming?
    All the things are happening for a reason, So dreams are for what? (12)
    I saw that there are lot of topics about their dreaming experiences and problems regarding to the
    dreams. But have you noticed that why are we dreaming. I believe that all the things happening in
    this universe is combined together. each of the natural phenomenas have a relationship among them.
    So dreaming for what?. One of my physics lecturer said that dreams make human more civilized. He
    said that naturally the human is just a kind of a beast. The secret of civilization of human is
    dreaming. I mean that not the having hopes, just dreaming while in sleep. It may quite m....
  5. Adding Flash Music Player To Home/any Page
    How-to (put any song you want!!!) (4)
    Want to put music on all pages (near the top)? Want any song you want? Well heres how! Place the
    following IN PLACE of the tag (paste in while thats highlighted. The text in red you HAVE to
    replace with the song url. The text in green is OPTIONAL (whether you want it to autostart or not.
    Right now it doesnt, if you want it to replace no with yes.) Of course place this in Admin
    Cp>>>Skinning and Styles>>>Board Wrappers>>>Header and Body QUOTE REPLACE THIS
    WITH YOUR SONG URL &autoStart= no " /> src="http://www.podbean.com/podcast-au....
  6. What Would You Rather Change In Windows
    minor things that annoy me in Windows (5)
    This is not a Win/Linux/Mac dispute, rather pointing out a few minor things that I find really
    annoying in Windows OS and I'd rather change if I had the chance/knowledge (disclaimer: I mainly
    refer to winxp but I've used almost all other versions, I have some experience with Linux and
    almost never used a Mac OS) copying/moving files: ever tried to copy a folder containing one or
    more corrupted files? if I were the OS I'd just skip those and copy the good ones, then prompt a
    message "file x, y, z were not copied we're sorry for the inconvenience caused".....
  7. Some Of The Biggest Questions In Life.
    Things that make you go hmmmm... (3)
    NUMBER ONE! The current world record for a 100m dash is 9.72 seconds right?? But it's been
    broken before and it's more than likely that at some point it will be broken. So what is the
    highest that the 100m dash record will ever go. Technically there is no maximum that the record can
    get to right? I mean you can always go a bit faster. But there also must be a limit to how fast
    people can travel right? Everyone says you cant go faster than the speed of light, as we know the
    speed of light equals 299 792 458 m / s right? So the maximum time that you can do it ....
  8. Can't Access My Site An Cpanel
    already did some sugested things (6)
    I still can't get to my website and cpanel, Tings I did: requested xisto to unblock my ip
    cleaned my cache/cookies Did this with both IE and FF When I am @ my dads house he can acces my
    website. So I guess it is still an ip problem. I did read some posts but couldn't find a
    solution. Thx in advance,....
  9. Things I Hate.
    (11)
    Here are a few things I just thought I'd let you know that I hate. Two-faced people. People
    who don't shut up and stop whining about the war. Stupid people. Liberals. People who are on
    welfare who really shouldn't be. Your dad. Hahahaha just kidding. Badly-behaved children.
    People who don't pay well when you babysit their demon children. TAKS testing. Algebra. My
    lack of talent. How easily I get bruised. Taxing. Hillary Clinton. Barrack Obama. Ted Kenedy.
    Al Gore. Ummmm. I'll add more later.....
  10. Adding Jigsaw Puzzle Effect With Photoshop
    (2)
    Should the occasion arise that you want to add a puzzle effect to a picture, there is a simple
    method built into Photoshop. Like a lot of other abilities, the hard part is finding it. Let me walk
    you through how I do it. There are a variety of other ways and I would love to hear your way also.
    So I have this picture of my cat that I want to look like a puzzle: I tune it up how I like it
    and size it, etc. Then click on Filter/Texture/Texturizer Once you click that a box appears:
    On the right hand panel you see Ok, Cancel. Texturizer then Brick or Sandston....
  11. Php Ftp Upload Form
    Adding User Directory to PHP Upload Form - Help (1)
    Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
    folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
    directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
    upload things into the main directory, only sub-directories, is that possible with this coding that
    I have: //uses $_FILES global array //see manual for older PHP version info //This
    function will be used to get the extension from the filename function get_extension($fi....
  12. Adding Drop Down Menus
    (7)
    I have looked around many IPB support sites, but I didn't find a suitable drop-down menu add-on
    that I liked or worked correctly. I have noticed the drop down menus on this forum on other forums,
    and I was wondering if this was custom to this site or there was a tutorial somewhere which shows
    how to make one similar to this? Or if anything, I basic IPB drop down menu tutorial/add on.
    Thanks.....
  13. Fast Food Secrets
    Things you probably dont what to know (13)
    QUOTE More than 60% of the restaurants had what experts refer to as "critical violations," which
    are benchmarks for judging a restaurant's cleanliness. Critical violations can fuel food-borne
    illnesses (such as salmonella) and, aside from that, are just nasty. The most common violations in
    fast-food chains? Employees not washing their hands (in some chains, there was no soap in the
    bathrooms), improper food holding temperatures, undercooked meat, and employees handling food with
    their bare hands. Fast-food meals contain common food allergy ingredients, but they....
  14. Disability And The General Public.
    Some things I've noticed. (4)
    Hi. My name's Kristina. I'm 14 years old, and I'm from Liverpool. I have Aspergers
    Syndrome, an Autistic Spectrum Disorder. I am Asthmatic. I have Eczema. I am short sighted. I am
    extremely allergic to house dust mites. I get hayfever. I suffer from chest and stomach migraines.
    I am currently on a few different kinds of medication. My Sister is Dyslexic, Dyspraxic, and has
    Irlens Syndrome. My Mum is also Dyslexic, and suffers with severe Psoriatic Arthritis and Sciatica,
    among other things. She also has Irlens Syndrome. She occasionally uses an el....
  15. Necessary College Things
    (10)
    I know for my first year of college I wasn't sure at all what I needed and what I didn't.
    Turns out I brought some of the necessary things, but left behind others that totally slipped my
    mind. Now that it's my second year, I feel like I did much better, but I'm wondering what
    other essentials I've forgotten. What are your favorite things that you have brought to
    college for your dorm living experience? So far I've found a mini fridge, microwave, and
    electronic tea kettle/coffee pot to be extremely useful and definitely necessary! Sometim....
  16. The State Of Trap17
    Some Things Are Getting Pretty Annoying Here (25)
    I, the founder of trap17, declare that this is one of the most hilarious topics ever made. Members
    please take your time to read this and do enjoy it. My special thanks to Buff and Velma. I
    personally ditest trap17 because of it's clutter, it's impossibility to navigate, and the
    fact that admins like buffalohelp haven't been banned yet, as he abuses his power to the point
    of threatening free speech. Trap17 is way to orienated on its appeal, and not it's content,
    which is what's really important. If you make something flashy but pointless, all your....
  17. Adding Shine To Text
    images say "Tiger Ads", but, the board is clsed, so, i'm r (4)
    OK, in this tut, I am going to show you how to add shine to any text. For this example I will be
    using the TigerAds affiliate button. (the board is since closed so, I'm not really advertising
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" />) OK then,
    lets get started! 1. Open up the image that you will be using, this is mine: 2.
    Now that your image is open and making sure that its the .psd so you can edit the text on it. In
    your layers menu, hold down CTRL and click on the text layer so that only the te....
  18. Adding Your Website To Google
    How to register with google (25)
    Hi everyone. Hopefully here im going to tell you how to register yourself with the Google search
    engine and get yourself in their results. Ill start the tutorial assuming you already have Meta
    tags or other search engine optimisation techniques in place. This tutorial is solely about
    registering with google. At one time i thought simply using meta tags etcetera would get you listed
    in Google, i then found out that didnt work, so i wondered why, and the fruits of my labour are what
    will go into this tutorial. the first step is to get a google account, this will get y....
  19. 20 Things To Do When You're Bored At Walmart
    (14)
    1.Make a trail of tomato juice leading towards the women's bathroom. 2.Ask to put a pack of gum
    on layaway. 3.Put antifreeze in the freezer. 4.Hide in the racks of clothing and grab people's
    ankles as they walk by. 5.Go into the fitting rooms and 5 min. later shout, "There isn't any tp
    in here!!!" 6.*Holiday Season* Ask an employee why there are white and black santas, but
    ne aboriganise santas. 7.Ride a display bike through the store and claim yo're taking it for a
    test drive. 8.Frozen pizza frisbe 9.Marco Polo. 10.Hold a broomstick joust. 1....
  20. The Reason Why People Get Drunk?
    Isn't there a 1,000,000 other things you can do? (37)
    OK i'm not talking about having a glass of wine a dinner. I'm also not talking about people
    who have drinking problems. I'm talking about why do people decide to get drunk for fun?
    Don't call me a prude cause i have drank before and even gotten into trouble at school for it. I
    did all of those because it was "cool" I have never understood why people just decide to get drunk
    though. One of my friends that comes over and is also one of the the main person in the O&J
    Productions crew (http://ojproductions.net my site) Always goes," we should get wasted ton....
  21. I Hate Site Builders.
    Mainly things like piczo and freewebs. (43)
    Loads of people i know, who have very little HTML knowledge, use Piczo . And now, anyone with one
    of these sites, think they have the best websites ever! All it usually is pictures and text
    randomly thrown on a page, with very-hard-to-navigate links. Freewebs is basically the same. I'm
    not sure about my space, I think it uses HTML, but I hate myspace websites. Anyways, back on the
    point, does anyone else know people who use piczo and think they are the best website builders in
    the world? I tried to teach one how to HTML, got stuck on tags /dry.gif" style="ve....
  22. School's Blocking System.
    Its not the smartest of things (28)
    The blocking system at school for blocking websites is stupid. It blocks pretty much any website you
    go to. If you go to school what is the blocking system like there? By the way I am posting this of a
    school computer /laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif"
    />....
  23. Long. 1 And Half Relationship. Any Advice? What Would You Do?
    (some things might not make sense, i just kep trailing on, sorry!) (4)
    Where to beginn.... me and my ex boyfriend, Chris, started out being best friends for about 2
    years. off and on he liked me but i didnt try to mess around with him because my other girlfriends
    like him as well. maybe a year later i couldnt help myself but to be interested in him and sooner or
    later we were going out. (dont worry my friends didnt like him then) So the beginning of the
    relationship it was good, we always promised we would be best friends and talked about how stupid it
    was that people wouldnt even talk to eachother after couples break up. everything was f....
  24. Adding Rows & Columns In Html Table Using Javascript
    (1)
    I'm trying to create a website with a form that collects some user information to store in MySQL
    database. However, I've a problem when I want to dynamically add new rows and columns in the
    HTML table so that the user can add more information in the dynamically added textboxes. Here's
    what I have: CODE                  <table border="0" width="90%"
    align="center" id="itemsTable">                   <tr>
                       <td width="20%">                     Quantity                   
    <....
  25. Most Romantic / Sweet Things To Do For Your Mate
    (16)
    Most Romantic / Sweet Things To Do For Your Girlfiend/Boyfriend QUOTE      1. Watch the
    sunset together. 2. Whisper to each other.             3. Cook for each other. 4. Walk in the
    rain. 5. Hold hands.      6. Buy gifts for each other.       7. Roses.     8. Find out
    their favorite cologne/perfume and wear it every time you're together. 9. Go for a long walk
    down the beach at midnight. 10. Write poetry for each other. 11. Hugs are the universal
    medicine. 12. Say I love you, only when you mean it and make sure they know you mean....
  26. Things Guys Should Know About Girls
    (44)
    Another mail I recieved... No assumptions please.. /tongue.gif" style="vertical-align:middle"
    emoid=":P" border="0" alt="tongue.gif" /> QUOTE Things guys should know about girls
    1. Don't ever lie to us; we always find out. 2. We don't enjoy talking dirty to you as
    much as you enjoy listening. 3. Don't say you understand when you don't. 4. Girls are
    pretty, but yours is the Prettiest! 5. You don't have PMS; don't act like you know what
    it's like. 6. Saying something sweet might get you off the hook; doing something s....
  27. 25 Things You *don"t* Want To Know!
    Trust Me (15)
    QUOTE 1) If you yelled for 8 years, 7 months and 6 days, you would have produced enough sound
    energy to heat one cup of coffee. (Hardly seems worth it!) 2) If you fart consistently for 6
    years and 9 months, enough gas is produced to create the energy of an atomic bomb. 3) The human
    heart creates enough pressure when it pumps out to the body to squirt blood 30 feet. 4) A pig's
    orgasm lasts for 30 minutes! 5) Banging your head against a wall uses 150 calories an hour.
    (Still not over that pig thing!) 6) Humans and dolphins are the only species that have....
  28. Visual Basic 6.0 Help Needed
    Adding lines to a textbox without delete (15)
    I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
    lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
    Help is appreciated!....
  29. Making Winrar Archives
    and adding password to winrar archives (13)
    **** This tutorial will show you how to put files into .rar Archive and pass worded (if wanted)
    **** What You Will Need Before continuing you will need a couple of thing, first of all you
    need WINRAR , which is a very powerful archive manager. It can reduce size for you email
    attachments, decompress RAR, ZIP and other types of files downloaded from the internet. You can get
    winrar at http://www.rarlabs.com The other thing is that make sure your using Windows XP because
    this is what I used to make this tutorial. I think it works with any other windows not....
  30. Name 3 Things That Make You Real Mad
    (94)
    Hi Here are my three to get this started: 1) I hate when I see humans mistreating animals for no
    reason. 2) I hate dumb people, I mean I really do. When confronted with someone that is plain dumb
    I get irrate. /mad.gif' border='0' style='vertical-align:middle' alt='mad.gif' /> 3)
    Disrespect. When someone talks to you like your are a piece of chewed gum on the pavement. I also
    hate it when I see someone else being the victim of this. Like a customer in a restaurent being rude
    to a waiter/waitress just because he can. So what gets your blood boiling? /wink.gi....

    1. Looking for sum, adding, things

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for sum, adding, things

*MORE FROM TRAP17.COM*
Similar
Archive.org The Public Domain And Basic Copyright - Archive.org is a great place to download old movies and things.
Destination Address For "submit" Button - Adding a destination email address to a "Submit" button
Things To Know About Dreams - Symbols, dream phonomenons, symbolic characters, kinds of dreams, colo
Why Are We Dreaming? - All the things are happening for a reason, So dreams are for what?
Adding Flash Music Player To Home/any Page - How-to (put any song you want!!!)
What Would You Rather Change In Windows - minor things that annoy me in Windows
Some Of The Biggest Questions In Life. - Things that make you go hmmmm...
Can't Access My Site An Cpanel - already did some sugested things
Things I Hate.
Adding Jigsaw Puzzle Effect With Photoshop
Php Ftp Upload Form - Adding User Directory to PHP Upload Form - Help
Adding Drop Down Menus
Fast Food Secrets - Things you probably dont what to know
Disability And The General Public. - Some things I've noticed.
Necessary College Things
The State Of Trap17 - Some Things Are Getting Pretty Annoying Here
Adding Shine To Text - images say "Tiger Ads", but, the board is clsed, so, i'm r
Adding Your Website To Google - How to register with google
20 Things To Do When You're Bored At Walmart
The Reason Why People Get Drunk? - Isn't there a 1,000,000 other things you can do?
I Hate Site Builders. - Mainly things like piczo and freewebs.
School's Blocking System. - Its not the smartest of things
Long. 1 And Half Relationship. Any Advice? What Would You Do? - (some things might not make sense, i just kep trailing on, sorry!)
Adding Rows & Columns In Html Table Using Javascript
Most Romantic / Sweet Things To Do For Your Mate
Things Guys Should Know About Girls
25 Things You *don"t* Want To Know! - Trust Me
Visual Basic 6.0 Help Needed - Adding lines to a textbox without delete
Making Winrar Archives - and adding password to winrar archives
Name 3 Things That Make You Real Mad
advertisement



Sum - Adding things



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE