News: Welcome to the TinyPortal Support site.

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

November 16, 2019, 09:45:50 PM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189259
  • Total Topics: 20772
  • Online Today: 201
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 188
Total: 188

Author Topic: Calculate total block  (Read 5787 times)

0 Members and 1 Guest are viewing this topic.

Cassiie

  • Guest
Calculate total block
« on: November 03, 2009, 08:00:22 PM »
Hi folks :)  I'm hoping someone here can help me.  The (World of Warcraft) guild I am in uses a very simple DKP system for looting.   I would like to get my hands on a block that my users can input a whole number, have the code subtract 20% from that number, and display the result.

Should be pretty simple for my members to do for themselves but evidently some of them aren't familiar with simple math  :-\

Thanks in advance.

JPDeni

  • Guest
Re: Calculate total block
« Reply #1 on: November 03, 2009, 08:12:09 PM »
Goes into a php block.

Code: [Select]
global $settings, $scripturl;

$number = '';
 echo '<div style="text-align:center">';
if (isset($_POST['get_answer']))
{
  if ($_POST['number'] <> '')
    $number= $_POST['number'];
  echo '<br />Your number was ' , $number , '<br />';
  echo '<br />The answer is ';
  $answer = $number x .8;
  echo $answer;
  echo '</div><br /><hr /><br />';
}

  $str = getenv("QUERY_STRING");
  if ($str)
    $action = 'index.php?'.$str;
  else
    $action = 'index.php';
  echo '<div style="text-align:center">Enter your number';
  echo '<form  action="',$action,'" method="post">';
  echo '<input type="hidden" name="get_answer" value="1">';
  echo '<input type="text" name="number" value="">';
  echo '<input type="submit" value="Tell me!">';
  echo '</form></div>';

echo '</div>';

Cassiie

  • Guest
Re: Calculate total block
« Reply #2 on: November 03, 2009, 08:16:44 PM »
Holy Smokes that was fast!  Thank you!

JPDeni

  • Guest
Re: Calculate total block
« Reply #3 on: November 03, 2009, 08:20:27 PM »
It was easy. I have a block on my site that takes input and prints out an answer. It was just a matter of taking out a little code and adding a little bit back in.

Cassiie

  • Guest
Re: Calculate total block
« Reply #4 on: November 03, 2009, 08:31:48 PM »
:( 

Quote
Parse error: syntax error, unexpected T_STRING in /home7/*******/public_html/******/home/Sources/Load.php(1739) : eval()'d code(48) : eval()'d code on line 11

If this is a pain, I'll just send them all calculators.  lol. I do appreciate your time :)

JPDeni

  • Guest
Re: Calculate total block
« Reply #5 on: November 03, 2009, 08:38:33 PM »
Oy vey!

I can't believe I did that! I knew better than that when I first learned programming 30 years ago!

Try this.

Code: [Select]
global $settings, $scripturl;

$number = '';
 echo '<div style="text-align:center">';
if (isset($_POST['get_answer']))
{
  if ($_POST['number'] <> '')
    $number= $_POST['number'];
  echo '<br />Your number was ' , $number , '<br />';
  echo '<br />The answer is ';
  $answer = $number * .8;
  echo $answer;
  echo '</div><br /><hr /><br />';
}

  $str = getenv("QUERY_STRING");
  if ($str)
    $action = 'index.php?'.$str;
  else
    $action = 'index.php';
  echo '<div style="text-align:center">Enter your number';
  echo '<form  action="',$action,'" method="post">';
  echo '<input type="hidden" name="get_answer" value="1">';
  echo '<input type="text" name="number" value="">';
  echo '<input type="submit" value="Tell me!">';
  echo '</form></div>';

echo '</div>';


Cassiie

  • Guest
Re: Calculate total block
« Reply #6 on: November 03, 2009, 08:39:48 PM »
You are SO my hero!  Thank you!

JPDeni

  • Guest
Re: Calculate total block
« Reply #7 on: November 03, 2009, 08:44:40 PM »
:) You're welcome.

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: Calculate total block
« Reply #8 on: November 03, 2009, 11:23:04 PM »
Amazing Deni  :up:  :)

Offline Freddy

  • Code
  • *
  • Posts: 1615
    • AiDreams
Re: Calculate total block
« Reply #9 on: November 04, 2009, 02:22:34 AM »
Nice one JP, very speedy too :)