Nicholas16 Posted July 18, 2009 Share Posted July 18, 2009 ive set my website up but when i used my energy up, it doesnt go to 0% it stays at 100%, but when i use the gym again, it says you dont have any energy left. this is the coding i got, i figured i went wrong... <b>Energy:</b> 100%<br /> <img src=gold.gif width=70 height=6><img src=red.png width=30 height=6><br /> can anyone tell me the actural coding so it goes up and down in %. would help me out alot. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 18, 2009 Share Posted July 18, 2009 you need to be more specific. is it a game? is the game using a database or file? how are you calculating the % sorry but my wand gon wrong. Quote Link to comment Share on other sites More sharing options...
Nicholas16 Posted July 18, 2009 Author Share Posted July 18, 2009 you need to be more specific. is it a game? is the game using a database or file? how are you calculating the % sorry but my wand gon wrong. is it a game? yes, its a text-based game is the game using a database or file? php file. how are you calculating the %? what do you mean? Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 18, 2009 Share Posted July 18, 2009 quick easy example ok. that means this in percentage. 50 points 10% 100 points 20% 200 points 40% 300 points 100% you work the rest out ok, you set the rules of percentage what equal's what. Remember php is a programming language, You create the programs with, there features. there is no set code for anything you create the code with your imagination using php and a database flat file or what ever. . <?php $current_points=300; switch ($current_points){ CASE (200); $current_percentage="40%"; break; CASE (300); $current_percentage="100%"; break; } echo "your current percentage is: $current_percentage"; ?> Quote Link to comment Share on other sites More sharing options...
Nicholas16 Posted July 18, 2009 Author Share Posted July 18, 2009 where do i put <b>Energy:</b> 100%<br /> <img src=gold.gif width=70 height=6><img src=red.png width=30 height=6><br /> in this coding? can anyone help me? <?php $current_points=300; switch ($current_points){ CASE (200); $current_percentage="40%"; break; CASE (300); $current_percentage="100%"; break; } echo "your current percentage is: $current_percentage"; ?> Quote Link to comment Share on other sites More sharing options...
Amtran Posted July 18, 2009 Share Posted July 18, 2009 You add it in like this: <?php $current_points = 300; switch ($current_points) { case 200: $current_percentage = "40%"; break; case 300: $current_percentage = "100%"; break; } echo '<b>Energy:</b>' . $current_percentage . '<br>'; echo '<img src="gold.gif" width="70" height="6"><img src="red.png" width="30" height="6"><br />'; ?> Quote Link to comment Share on other sites More sharing options...
Nicholas16 Posted July 18, 2009 Author Share Posted July 18, 2009 ok thanks but erm, when i did it on my test index.php, the Energy writing just disappears, is that right? Quote Link to comment Share on other sites More sharing options...
Amtran Posted July 18, 2009 Share Posted July 18, 2009 What do you mean? What do you actually see? Quote Link to comment Share on other sites More sharing options...
Nicholas16 Posted July 19, 2009 Author Share Posted July 19, 2009 nothing lol, before i put that coding in it was like Energy: 100% Will: 100% Brave: 10/10 Health: 100% but once i put that coding in, it says Will: 100% Brave: 10/10 Health: 100% Quote Link to comment Share on other sites More sharing options...
Batosi Posted July 19, 2009 Share Posted July 19, 2009 Dont do it like that.. <?php $max_energy = 500; $energy = (round($player_energy/$max_energy)*100); echo 'Energy '.$energy.'% <br>'; ?> Quote Link to comment Share on other sites More sharing options...
ignace Posted July 19, 2009 Share Posted July 19, 2009 Dont do it like that.. <?php $max_energy = 500; $energy = (round($player_energy/$max_energy)*100); echo 'Energy '.$energy.'% <br>'; ?> I agree with Batosi Quote Link to comment 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.