Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.