TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 07:13:38 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 190
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 67
  • Total: 68
  • @rjen

Calculate total block

Started by Cassiie, November 04, 2009, 03:00:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cassiie

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

Goes into a php block.


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

Holy Smokes that was fast!  Thank you!

JPDeni

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

:( 

QuoteParse 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

Oy vey!

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

Try this.


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

You are SO my hero!  Thank you!

JPDeni


G6Cad


Freddy


Renegd98