Jump to content

whats the actural coding?


Nicholas16

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/166420-whats-the-actural-coding/
Share on other sites

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?

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";

?>

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";

?>

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 />';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.