just me and php Posted February 17, 2007 Share Posted February 17, 2007 Is there a way i can add these together and get the sum as a number if($i==0){$f1000='100';} if($i==1){$f1000='99';} if($i==2){$f1000='98';} if($i==3){$f1000='97';} if($i==4){$f1000='96';} if($i==0){$f2000='100';} if($i==1){$f2000='99';} if($i==2){$f2000='98';} if($i==3){$f2000='97';} if($i==4){$f2000='96';} if($f1000=$i+$f2000=$i){$f3000='sum';} echo "<td align=left bgcolor=$bgcolor id='title'><font face='Verdana' size='2'><font color='$fontcolormp'><B>$f3000</B></font></a></td>\n"; and i get sum as output but i want a number not sum Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/ Share on other sites More sharing options...
kenrbnsn Posted February 17, 2007 Share Posted February 17, 2007 Add what together? Your "if" statement makes no sense. Ken Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/#findComment-187261 Share on other sites More sharing options...
just me and php Posted February 17, 2007 Author Share Posted February 17, 2007 hmm ok the page outs a list as peeps post fast times list goes like this this if statement makes up the points if($i==0){$f1000='100';} if($i==1){$f1000='99';} if($i==2){$f1000='98';} if($i==3){$f1000='97';} if($i==4){$f1000='96';} points 1.blablabla 100 2.blablabla 99 3.blablabla 98 ect.... it also outputs total lap time this if statement makes up the points for total time if($i==0){$f2000='100';} if($i==1){$f2000='99';} if($i==2){$f2000='98';} if($i==3){$f2000='97';} if($i==4){$f2000='96';} points 1.blablabla 100 2.blablabla 99 3.blablabla 98 ect.... and yes this if statment makes no sence cause it dont work and im asking if there is a way to make it work if($f1000=$i+$f2000=$i){$f3000='sum';} so you take the 1. spot at top and added it to the number 1. spot at bottom and get 200 same as 2. 3. 4. 5. ect... Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/#findComment-187456 Share on other sites More sharing options...
sspoke Posted February 17, 2007 Share Posted February 17, 2007 if($f1000=$i+$f2000=$i){$f3000='sum';} you cant use soo much equals in your IF your problem is not coding its logic gotta learn logic Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/#findComment-187458 Share on other sites More sharing options...
JJohnsenDK Posted February 17, 2007 Share Posted February 17, 2007 simple, but it should point you in the right direction. $i = 0; $f1000 = 0; $f2000 = 0; if($i == 0){ $f1000 = 100; }elseif ($i == 1) { $f1000 = 99; } if($i == 0){ $f2000 = 100; }elseif ($i == 1) { $f2000 = 99; } if(!empty($i)){ $sum = $f1000 + $f2000; } echo $sum; Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/#findComment-187466 Share on other sites More sharing options...
just me and php Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks JJohnsenDK il give that a try it looks good and SSpoke I need to lern both the coding and logic i know that an im trying Quote Link to comment https://forums.phpfreaks.com/topic/38933-is-there-a-way-to-add-these-as-a-number/#findComment-187535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.