Jump to content

Welcome to Pure Warfare - The #1 Community for Pures

Welcome to Pure Warfare - The #1 Community for Pures, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of Pure Warfare - The #1 Community for Pures by signing in or creating an account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get email updates
  • Get your own profile page and make new friends
  • Send personal messages to other members.

New PHP script


Tyler

Recommended Posts

I spent forever on this from trial and error. I know the form stuff from my HTML knowledge, but getting to to go to the .php thing took me forever.

 

Screenies below the scripts.

 

<html><head><title>Experience</title> </head><body><form method="post" action="table.php">  Current Exp: <input name="current" type="text" /><br />  Wanted Exp: <input name="wanted" type="text" /><br />  <input type="submit" /></form></body></html>

 

<?php  $current = $_REQUEST['current'];  $wanted = $_REQUEST['wanted'];  $maple = 45;  $yew = 60;  $magic = 75;echo '<table border="1" cellpadding="5">';echo '<th>Log Type</th><th>Experience Per Log</th><th>Logs Needed</th>';echo "<tr><td>Maple</td><td>$maple</td><td>";echo round("$wanted - $current" / $maple);echo "</td></tr>";echo "<tr><td>Yew</td><td>$yew</td><td>";echo round("$wanted - $current" / $yew);echo "</td></tr>";echo "<tr><td>Magic</td><td>$magic</td><td>";echo round("$wanted - $current" / $magic);echo "</td></tr>";echo "</table>";echo "<br />";echo "Thank you for using our Firemaking Calculator";echo "<br />";echo "I suggest buying 1 log above the given number for my lack of not knowing a round up fucntion;)"?>

 

It took me forever to get the table to get the variables to work in the table, and ended up having to do it the way it is making it look like a long script though it shouldn't be. I love learning through trial and error though :P

 

When you enter the numbers in the current exp and the wanted exp and hit submit query it sends you to the .php file with the log numbers calculated out :P

 

http://img143.imageshack.us/img143/9638/forme.png <- Form page

http://img225.imageshack.us/img225/1954/tableq.png <- Table results

Vim
|Tyler| - #Zulus
8818 person to achieve 99 Mining
ascreborn.png
Tyler.png

Omni was here lOL
Link to comment
Share on other sites

echo round("$wanted - $current" / $maple);

 

Change the "round" in the lines that like like the on above to "ceil", it is the round up function. Thanks Jay.

Vim
|Tyler| - #Zulus
8818 person to achieve 99 Mining
ascreborn.png
Tyler.png

Omni was here lOL
Link to comment
Share on other sites

Rather than so many Echos, you can simply do:

 

		 echo <<<HTMLHTML code here		HTML;

I only had one echo before, but it wouldn't do the calculations =\

Vim
|Tyler| - #Zulus
8818 person to achieve 99 Mining
ascreborn.png
Tyler.png

Omni was here lOL
Link to comment
Share on other sites

You can also do it in one file, by doing this:

 

<html><head><title>Experience</title></head><body><form method="post" action="test.php">  Current Exp: <input name="current" type="text" /><br />  Wanted Exp: <input name="wanted" type="text" /><br />  <input type="submit" name="submit"/></form></body></html><?phpif (isset($_POST['submit'])) {  $current = $_REQUEST['current'];  $wanted = $_REQUEST['wanted'];  $maple = 45;  $yew = 60;  $magic = 75;		 echo <<<HTML<table border="1" cellpadding="5"><th>Log Type</th><th>Experience Per Log</th><th>Logs Needed</th><tr><td>Maple</td><td>$maple</td><td>HTML;echo round("$wanted - $current" / $maple);		 echo <<<HTML</td></tr><tr><td>Yew</td><td>$yew</td><td>HTML;echo round("$wanted - $current" / $yew);		 echo <<<HTML</td></tr><tr><td>Magic</td><td>$magic</td><td>HTML;echo round("$wanted - $current" / $magic);		 echo <<<HTML</td></tr></table><br />Thank you for using our Firemaking Calculator<br />I suggest buying 1 log above the given number for my lack of not knowing a round up fucntiomHTML;}?>


favadmin.png
IRC Nick - ``Karl
"You lost me at biased."
Need help? PM me

purewarfare.png
Link to comment
Share on other sites

<html><head><title>Experience</title></head><body><form method="post" action="test.php">  Current Exp: <input name="current" type="text" /><br />  Wanted Exp: <input name="wanted" type="text" /><br />  <input type="submit" name="submit"/></form></body></html><?phpif (isset($_POST['submit'])) {  $current = $_REQUEST['current'];  $wanted = $_REQUEST['wanted'];  $maple = 45;  $yew = 60;  $magic = 75;		 echo <<<HTML<table border="1" cellpadding="5"><th>Log Type</th><th>Experience Per Log</th><th>Logs Needed</th><tr><td>Maple</td><td>$maple</td><td>HTML;echo ceil("$wanted - $current" / $maple);		 echo <<<HTML</td></tr><tr><td>Yew</td><td>$yew</td><td>HTML;echo ceil("$wanted - $current" / $yew);		 echo <<<HTML</td></tr><tr><td>Magic</td><td>$magic</td><td>HTML;echo ceil("$wanted - $current" / $magic);		 echo <<<HTML</td></tr></table><br />Thank you for using our Firemaking CalculatorHTML;}?>

 

Final, it has the round up function in it now ;)

Vim
|Tyler| - #Zulus
8818 person to achieve 99 Mining
ascreborn.png
Tyler.png

Omni was here lOL
Link to comment
Share on other sites

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.   Paste as plain text instead

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