Jump to content

Which way is the best for this?


Mike D

Recommended Posts

I'm creating a website for an old game and I want an "library" wheres every monster and info about them.

I just don't want to write everything into tables, because it would not look good.

I have been trying to code something like this:

monsterdatabase.png

 

I just don't know to get it working, but my idea is that when somebody types in (for example) "Dragon" it would show info of a monster named "Dragon".

I don't know what is the best way to implent this, but I hope you guys can help :)

 

Sorry for my english :shy:

 

 

What I've googled, the "switch" function is a good option imo, but how I can use it for this purpose?

Link to comment
Share on other sites

You said you didn't want to use a Database for this... is there any particular reason why? A Database would be much easier though, SQL queries make it simple to search through data sets will would be ideal for what you're looking to do.

 

If you're set on not using a Database to hold the information on each Monster... you could use an XML file instead.

 

Then use SimpleXML or another parser to extract the monster information.

 

 

Link to comment
Share on other sites

You said you didn't want to use a Database for this... is there any particular reason why? A Database would be much easier though, SQL queries make it simple to search through data sets will would be ideal for what you're looking to do.

 

If you're set on not using a Database to hold the information on each Monster... you could use an XML file instead.

 

Then use SimpleXML or another parser to extract the monster information.

I did not mean tha I don't want to use Database for this, I ment that I don't want to create an epic sized html table :)

Can you help me with the SQL queries etc, I don't know much about those things :-[

 

When you say tables, do you mean as in a database or a HTML/CSS  layout?

 

If you mean for the layout of your webpage, I suggest you repost this in the CSS section of the forums

I ment that I don't want to create an epic sized html table :)

Link to comment
Share on other sites

Update :D

 

I changed my mind a bit, and made this:

dropdown2.png

 

Theres now a few options to choose from, and I got them to work so they will forward you to the home page :D

How I can get it to create a new table under and show information about the selected monster?

Heres my code so far.. (Yeah it looks terrible :D)

 

<td><center>Select a monster from the list: </center></td>
<td>
<form name='menuform'>
<select name='menu2' 
onChange='top.location.href = this.form.menu2.options[this.form.menu2.selectedIndex].value;
return false;'>
  <option value='/index.html' selected>King Black Dragon</option>
  <option value='/index.html'>Black Dragon</option>
  <option value='/index.html'>Black Demon</option>
  <option value='/index.html'>Guard</option>
</select>
</form></td>

Link to comment
Share on other sites

OK, so you have created a select list, presumably with an item of each type of "monster". So, now you need to implement a submit button so the user can submit their selection (although you should be building the select list dynamically). You may be wanting the selection to display automatically once the user changes the select list. That is absolutely possible. But, first get this working with a submit button then you can implement AJAX to do it dynamically.

 

If you do not understand how to build a database, make queries, join tables, etc. a forum post is not the right venue to provide that info. There are plenty of good tutorials on getting started with that. Assuming you know how to create a database and you know how to craft the queries to get the info you need, here is a very rudimentary script to get you started. I have left quite a bit out such as error handling, connecting to the database, etc. But, assuming there are no errors (I didn't test it) it should be a fully working script - of course you would need a database table with the requisite fields.

 

<?php

//Determine the selected monster
$selectedMonster = (isset($_POST['monster'])) ? trim($_POST['monster']) : false;

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

//If a monster was selected get the data
if($selectedMonster)
{
    $id = mysql_real_escape_string($selectedMonster);
    $query = "SELECT * FROM monsters WHERE id = {$id}";
    $result = mysql_query($query) or die(mysql_error());

    if(mysql_num_rows($result)=0)
    {
        $monsterOutput = "Monster not found.";
    }
    else
    {
        $monster = mysql_fetch_assoc($result);
        //Create output to display the monster data
        $monsterOutput .= "<table border='1'>\n";
        $monsterOutput .= "  <tr>\n";
        $monsterOutput .= "    <th>Name:<th><td>{$monster['name']}</td>\n";
        $monsterOutput .= "    <th>Hit Points:<th><td>{$monster['h_points']}</td>\n";
        $monsterOutput .= "    <th>Attack:<th><td>{$monster['attack']}</td>\n";
        $monsterOutput .= "    <th>Stamina:<th><td>{$monster['stamina']}</td>\n";
        $monsterOutput .= "  </tr>";
        $monsterOutput .= "</table>";
    }
}

//Run query to get list of ALL monster names/IDs to build select list
$query = "SELECT id, name FROM monsters ORDER by name";
$result = mysql_query($query) or die(mysql_error());
//Process results into options list
$monsterOptions = '';
while($row = mysql_fetch_assoc($result))
{
    $selected = ($row['id']===$selectedMonster) ? ' selected="selected"' : '';
    $monsterOptions .= "<option value=\"{$row['id']}\"{$selected}>{$row['name']}<option>\n";
}

?>
<html>
<head>

</head>
<body>

<form name="menuform">
<table>
  <tr>
    <td>Monster Database</td>
  </tr>
  <tr>
    <td><center>Select a monster from the list: </center></td>
    <td>
      <select name="monster">
        <?php echo $monsterOptions; ?>
      </select>
      <button type="submit">Submit</button>
    </td>
  </tr>
</table>
</form>

<?php echo $monsterOutput; ?>

</body>
</html>

Link to comment
Share on other sites

Thank you for your help!

 

I created the db "monster" and a table "monsters", heres the structure I wrote for it:

CREATE TABLE IF NOT EXISTS `monsters` (
`id`  int(10) NOT NULL auto_increment,
`name` char(25) NOT NULL,
`h_points` int(10) NOT NULL,
`attack` int(10) NOT NULL,
`stamina` int(10) NOT NULL,
PRIMARY KEY  (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

Theres no errors but it doesnt give me any information about the selected monster...

 

Oh wait, should I insert something here?

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

Link to comment
Share on other sites

Oh wait, should I insert something here?

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

 

No. That is simply declaring the variable that the code later uses to populate with the HTML "output" code for displaying the monster data (if one was selected). Are you getting any errors? You state "it doesnt give me any information about the selected monster..." so I assume that the select list is getting populated (you did leave the code to dynamically populate the select list, right?).

 

There is error handling in case the selected id is not int he database (i.e. the message "Monster not found." should display). Are you getting that message? Are you getting the display table but no data, what? More info please.

Link to comment
Share on other sites

Oh wait, should I insert something here?

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

 

No. That is simply declaring the variable that the code later uses to populate with the HTML "output" code for displaying the monster data (if one was selected). Are you getting any errors? You state "it doesnt give me any information about the selected monster..." so I assume that the select list is getting populated (you did leave the code to dynamically populate the select list, right?).

 

There is error handling in case the selected id is not int he database (i.e. the message "Monster not found." should display). Are you getting that message? Are you getting the display table but no data, what? More info please.

 

Yeah it populates the select list itself, I didn't touch the code, I just added these lines to the top of the code:

 

mysql_connect('localhost', 'abc123, 'abc123'); 
mysql_select_db('monster'); 

 

When I select one and click submit, the url will change to like: test.php?monster=66

But it doesn't display anything, not even the "Monster not found" message nor the table..

Link to comment
Share on other sites

try changing

mysql_connect('localhost', 'abc123, 'abc123'); 

 

to

 

mysql_connect('localhost', 'abc123', 'abc123'); 

 

you missed a '

Oh it was my mistake when I changed my login credentials before posting it here, I have it right in the code :)
Link to comment
Share on other sites

OK, I see the problem. I didn't specify a method on the form and it defaulted to the GET method, but the code was looking for the selected value in the POST method.

 

Change the form to

<form name="menuform" method="post">

 

Yey! thanks, it works now :)

It's perfect!

 

I owe you one :D

Link to comment
Share on other sites

I ran into another small problem..

The code works as it should, but I don't know why it doesn't work when I put it into my "innerContentSwitch.php" file.

The website's "home" page, (aka index.php) has a few links that are linked to the "innerContentSwitch.php".

For example the link to Rules page:

<a href='?query=rules' target='_self'>Rules</a>

And in the "innerContentSwitch.php" theres this:

		case "rules":
		echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Rules.png'></div><div class='content'>";

		$file = array_map('rtrim',file('infrastructure/content/rawdata/rules2.txt'));
		for($i=0;$i<count($file);$i++){
			echo str_replace("\$SERVER_NAME\$", $web_primary_name, $file[$i]) . "<br />";
		}
		echo "</div></div>";
	break;

 

I added this to the index.php:

<a href='?query=npc_drops' target='_self'>Monster DB</a>

 

And this to the innerContentSwitch.php:

case "npc_drops":
<?php


mysql_connect('localhost', 'xxx', 'xxx'); //your credentials
mysql_select_db('monster'); //you credentials

//Determine the selected monster
$selectedMonster = (isset($_POST['monster'])) ? trim($_POST['monster']) : false;

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

//If a monster was selected get the data
if($selectedMonster)
{
    $id = mysql_real_escape_string($selectedMonster);
    $query = "SELECT * FROM monsters WHERE id = {$id}";
    $result = mysql_query($query) or die(mysql_error());

    if(mysql_num_rows($result)==0)
    {
        $monsterOutput = "Monster not found.";
    }
    else
    {
        $monster = mysql_fetch_assoc($result);
        //Create output to display the monster data
        $monsterOutput .= "<table border='0'>";
        $monsterOutput .= "  <tr>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Name:</font><th><td><font color=#FFFFFF>{$monster['name']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Hit Points:</font><th><td><font color=#FFFFFF>{$monster['h_points']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Attack:</font><th><td><font color=#FFFFFF>{$monster['attack']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Stamina:</font><th><td><font color=#FFFFFF>{$monster['stamina']}</font></td>\n";
        $monsterOutput .= "  </tr>";
        $monsterOutput .= "</table>";
    }
}

//Run query to get list of ALL monster names/IDs to build select list
$query = "SELECT id, name FROM monsters ORDER by name";
$result = mysql_query($query) or die(mysql_error());
//Process results into options list
$monsterOptions = '';
while($row = mysql_fetch_assoc($result))
{
    $selected = ($row['id']===$selectedMonster) ? ' selected="selected"' : '';
    $monsterOptions .= "<option value=\"{$row['id']}\"{$selected}>{$row['name']}<option>";
}

?>

<form name="menuform" method="post">
<table>
  <tr>
    <td>Monster Database</td>
  </tr>
  <tr>
    <td><center><font color=#FFFFFF>Select a monster from the list: </font></center></td>
    <td>
      <select name="monster">
        <?php echo $monsterOptions; ?>
      </select>
      <button type="submit">Submit</button>
    </td>
  </tr>
</table>
</form>
</body>
</html>
<?php echo $monsterOutput; ?>
</body>
break;

 

 

 

It gives me some errors, for example:

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\www\infrastructure\content\innerContentSwitch.php on line 1378

 

This is the line which causes the error:

<form name="menuform" method="post">

 

 

I don't know how to explain it better, but if you need more information, just ask..

Link to comment
Share on other sites

Post the full file, we cannot fix parse errors with part of a file.

Sure..

Theres just 1450 lines in the document..

I removed some parts that I know that they are not important.. (Max. 4000 letters per post)

Here we go:

 

 

 

<html>
<body>
<?php	
$mirror_list = 	array(
			0 => array('2Shared','http://www.2shared.com/file/upMd2rqD/Dunno_Client.html','December 8th 2010')
);
switch($query){

	case "highscores":
		$grabskill = isset($_GET['skill']) ? trim(strtolower($_GET['skill'])) : null;
		$search_type = isset($_GET['type']) && $_GET['type'] == 1 ? 1 : 0;
		$user_search = empty($_GET['user']) ? null : ((strlen($_GET['user']) <= 20 && $search_type == 0 || strlen($_GET['user']) <= 11 & $search_type == 1) ? $_GET['user']: null);
		echo "<form method='get' action=''><input type='hidden' name='query' value='highscores' /><input type='hidden' name='type' value='1' /><div class='table'><div class='header'><img src='infrastructure/content/images/Character Search.png'></div></br></br><div class='content'><table><tr><td style='width:30%;'><font face=Times New Roman color=#FFFFFF>Enter character name:</font></td><td style='width:50%;text-align:center;'><input type='text' name='user' maxlength='11' value='" . (($search_type == 1 && isset($user_search)) ? $user_search : null) . "' /></td><td style='text-align:right;width:20%;'><input type='submit' value='Search' /></td></tr></table></div></div></form>";
		if(isset($user_search)){
			$queryLine = ($search_type == 1) ? $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.username = '" . $db->escape($user_search) . "' LIMIT 0 , 1") : $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.user = '" . $db->escape($user_search) . "' LIMIT 0 , 1");
			$userdata = $db->fetch_assoc($queryLine);
			if(isset($userdata['id'])){
				echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Account Info</div><div class='content'><table><tr><td style='width:50%;'>Character Name</td><td>" . ucfirst($userdata['username']) . "</td></tr><tr><td style='width:50%;'>Account Name</td><td><a href='" . PUN_ROOT . "profile.php?id=" . $userdata['owner'] . "'>" . $userdata['account_name'] . "</a></td></tr><tr><td style='width:50%;'>Combat</td><td>" . $userdata['combat'] . "</td></tr><tr><td>Character Registered</td><td>" . date("M d Y", $userdata['creation_date']) . "</td></tr><tr><td>Last Login</td><td>" . date("M d Y", $userdata['login_date']) . "</td></tr></table></div></div>";
				echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Skill Sheet</div><div class='content'><a style='display:block;text-align:right;' href='?query=highscores'>Go back to highscores?</a><br />";
				if($userdata['highscoreopt'] == 1){
					echo "This user has chose to hide their skills.";
				} else {
					echo "<table><tr><td style='width:50%;'>Skill</td><td style='width:25%;'>Level</td><td style='width:25%;'>Experience</td></tr>";
					for($i=0; $i < count($skills); $i++){
						echo"<tr><td><a href='?query=highscores&skill=" . $skills[$i] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[$i] . ".png' alt='X' /> " . ucfirst($skills[$i]) . "</a></td><td>" . experience_to_level($userdata['exp_' . $skills[$i]]) . "</td><td>" . number_format($userdata['exp_' . $skills[$i]]) . "</td></tr>";
					}
					echo "</table>";
				}
				echo"</div></div>";
			} else {
				echo createTable("This user does not exist. <a href='?query=highscores'>Go back to highscores?</a>");
			}
		} else {
			echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Highscores2.png'></div></br></br><div class='content'><table>";
			for($i = 1; $i < count($skills); $i++){
					echo (($i == 1) ? "\n<tr>\n" : null) . "<td><a href='?query=highscores&skill=" . $skills[($i - 1)] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[($i - 1)] . ".png' alt='x' />" . ucfirst($skills[($i - 1)]) . "</a></td>\n" . (($i > 0 && $i % 4 == 0) ? "\n</tr>\n<tr>\n" : null);
			}
			echo "\n<td><a href='?query=highscores&skill=skill_total'> Skill Total</a></td><td><a href='?query=highscores&skill=combat'> Combat</a></td><td> </td></tr></table></div></div>\n\n";
			if(in_array($grabskill, $skills) || $grabskill == 'combat' || $grabskill == 'skill_total'){
				(int)$startRow = isset($_GET['startrow']) && $_GET['startrow'] > 0 && $_GET['startrow'] % 20 == 0 ? $_GET['startrow'] : 0;
				$HS_QueryLine = ($grabskill == 'skill_total' ? "SELECT skill_total,user,username FROM rsca2_players ORDER BY skill_total DESC" : ($grabskill == 'combat' ? "SELECT username,user,combat FROM rsca2_players ORDER BY combat DESC" : "SELECT DISTINCT(rsca2_experience.user), rsca2_experience.highscoreopt, rsca2_experience.exp_" . $grabskill . ", rsca2_players.username FROM rsca2_experience JOIN rsca2_players ON rsca2_experience.user = rsca2_players.user WHERE rsca2_experience.highscoreopt = 0 AND rsca2_experience.exp_" . $grabskill . " > 0 ORDER BY rsca2_experience.exp_" . $grabskill . " DESC"));
				$generateHSList = $db->query($HS_QueryLine . " LIMIT " . $startRow . ", 20");
				echo "<div class='table'><div class='header'><table><tr><td style='width:70%;text-align:left;'>Skill Table for " . str_replace("_", " ", ucfirst($grabskill)) . "</td><td style='width:30%;text-align:right;'><a href='?query=highscores'>Close</a></td></tr></table></div><div class='content'>";
				if($db->num_rows($generateHSList) == 0){
					echo "No results found for this particular skill.";
				} else {
					$i = $startRow + 1;
					$getTotalRows = $db->num_rows($db->query($HS_QueryLine));
					$nextUp = (($startRow - 20) < 0) ? 0 : $startRow - 20;
					$nextDown = (($startRow + 20) > $getTotalRows) ? 0 : $startRow + 20;
					echo "<table><tr><td style='width:5%;'> </td><td style='width:55%;'>Username</td>" . ($grabskill == 'skill_total' ? "<td style='width:20%;'>Skill total</td><td> </td>" : ($grabskill == 'combat' ? "<td style='width:20%;'>Combat</td><td> </td>" : "<td style='width:20%;'>Level</td><td style='width:20%;'>Experience</td>")) . "</tr><tr><td colspan='4' style='height:22px;text-align:right;'>" . (($nextUp == 0 && $nextDown == 20 || $nextUp == 0 && $nextDown == 0) ? " " : "<a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextUp . "'><img src='" . $web_data['b_img'] . "/arrow_up.png' alt='^' /></a>") . "</td></tr>";
					while($r = $db->fetch_assoc($generateHSList)){
						echo "<tr><td>" . (($i <= 5) ? "<span style='font-weight:bold;'>" . $i . "</span>" : $i) . "</td><td><a href='?query=highscores&user=" . $r['user'] . "'>" . ucfirst($r['username']) . "</a></td> " . ($grabskill == 'skill_total' ? "<td>" . number_format($r['skill_total']) . "</td><td> </td>" : ($grabskill == 'combat' ? "<td>" . $r['combat'] . "</td><td> </td>" : "<td>" . experience_to_level($r['exp_' . $grabskill]) . "</td><td>" . number_format($r['exp_' . $grabskill]) . "</td>")) .  "</tr>";
						$i ++;
					}
					echo (($getTotalRows > 20) ? "<tr><td colspan='4' style='text-align:right;'><a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextDown . "'><img src='" . $web_data['b_img'] . "/arrow_down.png' alt='V' /></a></td></tr>" : null) . "</table>";
				}
				echo "</div></div>";
			}
		}
	break;
	case "players_online":
		$getMembers = $db->query("SELECT * FROM rsca2_players WHERE loggedin = 1 ORDER BY group_id DESC");
		$countMembers = $db->num_rows($getMembers);
		echo "<div class='table'><div class='header'>Players Online (" . $countMembers . ")</div><div class='content'>";
		if($countMembers > 0){
			$i = 0;

			while($doQuery = $db->fetch_assoc($getMembers)){
				switch($doQuery['group_id']){
					case 3: 
						echo "<img src='" . $web_data['b_img'] . "/mod/pmd.png' alt='[PMod]' />";
					break;
					case 2: 
						echo "<img src='" . $web_data['b_img'] . "/mod/mod.png' alt='[Mod]' />";
					break;
					case 1: 
						echo "<img src='" . $web_data['b_img'] . "/mod/adm.png' alt='[admin]' />";
					break;
					default: break;
				}
				echo "<a href='?query=highscores&lookup=" . $doQuery['user'] . "'>" . $doQuery['username'] . "</a>";
				if(($i + 1) == $countMembers){} else { echo ", "; }
				$i++;
			}
		} else {
			echo "There is currently no registered users logged in game.";
		}
		echo "</div></div>";
	break;
	case "cms":
		if($pun_user['is_guest']){
			echo $mustBeLoggedIn;
		} else {
			$totalchars = $db->num_rows($db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'"));
			$switchAct = isset($_GET['act']) ? strtolower(trim($_GET['act'])) : null;
			$cmsPre = "<div class='table'><div class='header'>CMS Response</div><div class='content'>";
			$cmsSuf = "</div></div>";
			echo "<div id='characterMS'>
			<div class='table'>
			<div class='header'><img src='infrastructure/content/images/Character Management System.png'></div>
			<div class='content'>
			</br>
			</br>
			</br>
				<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou are limited to <font size=3 face=Times New Roman color=#650c0c>10</font> characters per forum account.</font></center>
				<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou will be unable to multi-log with 2 characters on the same forum account.</font></center>";
				if(empty($pun_user['del_pin']) && $switchAct != 'set_pin'){
					echo "<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou have not yet set your character deletion pin, would like to set one</font> <a href='?query=cms&act=set_pin'>now</a>?</center>";
				}

				if($switchAct != 'addnew' && $totalchars < 10){
				echo "
					<br /><br /><center><font size=4 face=Times New Roman color=#650c0c>C</font><font size=3 face=Times New Roman color=#FFFFFF>lick</font> <a href='?query=cms&act=addnew'>here</a><font size=3 face=Times New Roman color=#FFFFFF> if you wish to add a new character.</font>
				";
			}
			if($totalchars >= 10){
				echo "<br /><br />Sorry but you currently have 10 characters and can not add more. You must either delete one or make a new forum account.";
			}
			echo "</div></div>";
			switch($switchAct){
				case "set_pin":
					if(!empty($pun_user['del_pin'])){
						echo createTable("You have already set a PIN.");
					} else {
						if(isset($_POST['set_pin'])){
							$pin1 = isset($_POST['pin_1']) ? (is_numeric($_POST['pin_1']) ? $_POST['pin_1'] : null) : null;
							$pin2 = isset($_POST['pin_2']) ? (is_numeric($_POST['pin_2']) ? $_POST['pin_2'] : null) : null;
							if($pin1 == null || $pin2 == null){
								echo createTable("You need to fill in both pin inputs, and ensure that the pin you entered is numeric.");
							} else if ( strlen($pin1) != 4 || strlen($pin2) != 4){
								echo createTable("Please ensure that your pin is 4 characters in length.");
							} else if ($pin1 != $pin2){
								echo createTable("Please ensure that your pins match eachother.");
							} else {
								$set_pin = $db->query("UPDATE users SET del_pin = '" . $pin1 . "' WHERE id = '" . $pun_user['id'] . "'");
								echo createTable("You have successfully set your character management pin. <a href='?query=cms'>Refreshing...</a><meta http-equiv='refresh' content='1;url=?query=cms' />", "Success");
							}
						}
						echo "
							<form method='post' action='?query=cms&act=set_pin'>
							<div class='table'>
								<div class='header'><img src='infrastructure/content/images/Set Deletion Pin.png'></div>
								<div class='content'>
									<table>
									<tr>
										<td style='width:20%;'>Write Pin</td>
										<td style='width:15%;'><input type='password' size='4' maxlength='4' name='pin_1' value='" . (isset($_POST['pin_1']) ? $_POST['pin_1'] : null) . "' /></td>
										<td style='width:65%;vertical-align:top;' rowspan='3'>
											If you are going to set a character deletion pin, please ensure that you can REMEMBER it, as this will become always required in order to delete characters.
										</td>
									</tr>
									<tr>
										<td>Confirm Pin</td>
										<td><input type='password' size='4' maxlength='4' name='pin_2' value='" . (isset($_POST['pin_2']) ? $_POST['pin_2'] : null) . "' /></td>
									</tr>
									<tr>
										<td>
											<input type='submit' name='set_pin' value='Set My Pin' />
										</td>
										<td>
											<a href='?query=cms'>Cancel</a>
										</td>
									</tr>
									</table>
								</div>
							</div>
							</form>
						";
					}
				break;
				case "opt":
					$cleanChar = (is_numeric($_GET['char']) && $_GET['char'] > 0) ? trim($_GET['char']) : null;
					if(isset($cleanChar)){
						$findInfo = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($cleanChar) . "'"));
						if($findInfo['owner'] == $pun_user['id']){
							$expSelect = $db->fetch_assoc($db->query("SELECT * FROM rsca2_experience WHERE user = '" . $findInfo['user'] . "'"));
							if($expSelect['highscoreopt'] == 0){
								$db->query("UPDATE rsca2_experience SET highscoreopt = '1' WHERE user = '" . $db->escape($cleanChar) . "'") or die();
								#echo "Setting to hide";
							} else {
								#echo "Setting to show";
								$db->query("UPDATE rsca2_experience SET highscoreopt = '0' WHERE user = '" . $db->escape($cleanChar) . "'") or die();
							}
						}
					}
				break;
				case "deletecharacter":
					$grab_char_id = isset($_GET['char']) ? $_GET['char'] : null;
					if(is_numeric($grab_char_id)){
						$checkdata = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'"));
						if($checkdata['owner'] == $pun_user['id']){
							if(isset($_POST['deletechar'])){
								if(!empty($pun_user['del_pin']) && $_POST['deletion_pin'] != $pun_user['del_pin']){
									echo createTable("The pin you entered was incorrect... <meta http-equiv='refresh' content='1;url=?query=cms'><a href='?query=cms'>refreshing momentarily</a>.");
									return;
								}
								$db->query("DELETE FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_curstats WHERE user = '" . $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_experience WHERE user = '" .  $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_invitems WHERE user = '" .  $db->escape($grab_char_id). "'");
								$db->query("DELETE FROM rsca2_logins WHERE user = '" .  $db->escape($grab_char_id) . "'");
								#echo $cmsPre . "<meta http-equiv='refresh' content='1;url=?query=cms'>Your character has been successfully deleted, <a href='?query=cms'>refreshing momentarily</a>." . $cmsSuf;
							} else {
							echo "
								<form method='post'>
									<div class='table'><div class='header'>Delete confirmation for '".$checkdata['username']."'</div>
									<div class='content'>
										Are you sure you wish to delete this character? This action is totally irreversible! <br />
										<table>
							";
							if(!empty($pun_user['del_pin'])){
								echo "
										<tr>
											<td style='width:50%;'>
												Enter Deletion Pin:
											</td>
											<td style='width:50%;text-align:right;'>
												<input type='password' name='deletion_pin' value='' size='4' maxlength='4' />
											</td>
										</tr>
								";
							}
							echo"
										<tr>
											<td style='width:50%;'>
												<input type='submit' value='Delete Character' name='deletechar' />
											</td>
											<td style='text-align:right;'>
												<a href='?query=cms'>Cancel</a>
											</td>
										</tr>
										</table>
									</div>
									</div>
								</form>
							";
							}
						} else {
							echo $cmsPre . "This is not your character." . $cmsSuf;
						}
					} else {
						echo $cmsPre . "Invalid Character ID." . $cmsSuf;
					}
				break;
				default:
				break;
			}

			echo "
			<div class='table'>
			<div class='header'><img src='infrastructure/content/images/My Existing Characters.png'></div>
			<div class='content'>";
			$fetchCharacters = $db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'");
			if($db->num_rows($fetchCharacters) > 0){

				echo "
				<table id='cmsTable' style='width:100%;'>
				<tr id='cmsHeaders'>
				<br></br>

					<td style='width:35%;'><font size=5 face=Times New Roman color=#FFFFFF>Character</font></td>
					<td style='width:20%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Password</font></td>
					<td style='width:35%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Highscore Opt</font></td>
					<td style='width:10%;text-align:right;'><font size=5 face=Times New Roman color=#FFFFFF>Delete</font></td>
				</tr>
				";
				while($r = $db->fetch_assoc($fetchCharacters)){
					$optCheck = $db->fetch_assoc($db->query("SELECT highscoreopt FROM rsca2_experience WHERE user = '" . $r['user'] . "'"));
					echo "<tr><td><a href='?query=highscores&lookup=" . $r['username'] . "&s_type=1'>" . $r['username'] . "</a></td><td style='text-align:center;'><a href='?query=cms&act=changepass&char=".$r['user']."'>Change</a></td><td style='text-align:center;'>" . (($optCheck['highscoreopt'] == 0) ? "<a href='?query=cms&char=" . $r['user'] . "&act=opt'>Hide</a>" : "<a href='?query=cms&act=opt&char=" . $r['user'] . "'>Show</a>") . "</td><td style='text-align:right;'><a href='?query=cms&act=deletecharacter&char=".$r['user']."'>X</a></td></tr>";
				}
				echo "
				</table>
				";
			} else {
				echo "You have not yet <a href='?query=cms&act=addnew'>added a character</a> to this account.";
			}
			echo "
			</div></div></div>
			";
		}
	break;

	case "login_page":
		require('quickLogin.php');
	break;

	case "rules":
		echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Rules.png'></div><div class='content'>";

		$file = array_map('rtrim',file('infrastructure/content/rawdata/rules2.txt'));
		for($i=0;$i<count($file);$i++){
			echo str_replace("\$SERVER_NAME\$", $web_primary_name, $file[$i]) . "<br />";
		}
		echo "</div></div>";
	break;
	case "combat_calculator":
		if(isset($_POST['calccomb']) || isset($_POST['calchits'])){
			$attack = isset($_POST['attack']) && is_numeric($_POST['attack']) && $_POST['attack'] > 0 && strlen($_POST['attack']) <= 2 ? $_POST['attack'] : null;
			$defense = isset($_POST['defense']) && is_numeric($_POST['defense']) && $_POST['defense'] > 0 && strlen($_POST['defense']) <= 2 ? $_POST['defense'] : null;
			$strength = isset($_POST['strength']) && is_numeric($_POST['strength']) && $_POST['strength'] > 0 && strlen($_POST['strength']) <= 2 ? $_POST['strength'] : null;
			$hits = isset($_POST['hits']) && is_numeric($_POST['hits']) && $_POST['hits'] > 0 && strlen($_POST['hits']) <= 2 ? $_POST['hits'] : null;
			$ranged = isset($_POST['ranged']) && is_numeric($_POST['ranged']) && $_POST['ranged'] > 0 && strlen($_POST['ranged']) <= 2 ? $_POST['ranged'] : null;
			$magic = isset($_POST['magic']) && is_numeric($_POST['magic']) && $_POST['magic'] > 0 && strlen($_POST['magic']) <= 2 ? $_POST['magic'] : null;
			$prayer = isset($_POST['prayer']) && is_numeric($_POST['prayer']) && $_POST['prayer'] > 0 && strlen($_POST['prayer']) <= 2 ? $_POST['prayer'] : null;
			/* CALC HITS */
			$totalexp = ($exps[($attack - 2)] + $exps[($defense - 2)] + $exps[($strength - 2)]);
			$divideexp = floor($totalexp / 3) + 1200;
			$convertexp = experience_to_level($divideexp);
			$hplvl = $convertexp;
			/* CALC COMB */
			if(!isset($_POST['calchits'])){
				echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Calculated Results.png'></div></br></br><div class='content'>";
				if($attack == null || $defense == null || $strength == null || $hits == null || $ranged == null || $magic == null || $prayer == null){
					echo "You either left a field blank or attempted to add bad data.";
				} else {
					$calcatkdefstr = (($attack + $defense + $strength + $hits) * .25);
					$calcmagicprayer = ($magic + $prayer) * 0.125;

					if(($attack + $strength) < ($ranged * 1.5)){
						$defhits = ($defense + $hits) * 0.25;
						$fixrange = $ranged * 0.375;
						$newcb = $defhits + $fixrange + $calcmagicprayer;
						$base = 0;
					} else {
						$base = 1;
						$newcb = $calcatkdefstr + $calcmagicprayer;
					}
					$nextcb = floor(($newcb) + 1) - $newcb;
					$nextFightLevel = (floor(($nextcb) / 0.25)) - 1;
					$nextPMLevel = (floor(($nextcb) / 0.125)) - 1;
					$nextRangeLevel = (floor(($nextcb) / 0.375));
					$atkDefAddTo = floor($ranged * 1.5);
					$nextFightLevel = $nextFightLevel < 0 ? 0 : $nextFightLevel;
					$nextPMLevel = $nextPMLevel < 0 ? 0 : $nextPMLevel;
					$nextRangeLevel = $nextRangeLevel < 0 ? 0 : $nextRangeLevel;
					echo "
						<table>
						<tr>
							<td style='width:40%;'>Combat Level</td>
							<td style='width:60%;'><span class='highlighter'>" . $newcb . "</span></td>
						</tr>
						<tr>
							<td style='width:40%;'>Character Base</td>
							<td style='width:60%;'>" . ($base == 0 ? "Ranger" : "Fighter") . "</td>
						</tr>
					";if($hits < 10 || $newcb < 3.5){
					echo "<tr><td valign='top'>Extra Notes</td><td>Administrative character. <br />[ Detected < 10 hp || cblvl < 3.5]</td></tr>"; }
					if($base == 0){
						echo "
							<tr>
								<td valign='top'>You can max out with:</td>
								<td>" . $nextRangeLevel . " more ranged level(s).<br />" . $nextFightLevel . " more defense or hits level(s).<br /> " . $nextPMLevel . " more magic or prayer level(s).
								<br /><br />Because you are primarily a ranger, if you DO NOT raise your ranged level, your attack and strength will have NO effect on your combat level until they add to " . $atkDefAddTo . "


								</td>
							</tr>
						";
					} else {
						echo "
							<tr>
								<td valign='top'>You can max out with:</td>
								<td>" . $nextFightLevel . " more attack, defense, or strength level(s). <br />" . $nextPMLevel . " more magic or prayer level(s).</td>
							</tr>
						";
					}
					echo "
						</table>
					";
				}
				echo "</div></div>";
			}
		}
		echo "
		<form method='post'><div class='table'><div class='header'><img src='infrastructure/content/images/Combat Calculator2.png'></div></br></br><div class='content'>
		<input type='hidden' name='query' value='combat_calculator' />
		<table style='width:75%;margin:auto;'>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Attack</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['attack']) && !isset($_POST['clearit']) ? $_POST['attack'] : 1) . "' name='attack' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Defense</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['defense']) && !isset($_POST['clearit']) ? $_POST['defense'] : 1) . "' name='defense' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Strength</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['strength']) && !isset($_POST['clearit']) ? $_POST['strength'] : 1) . "' name='strength' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Hits</font></td>
			<td style='width:50%;'>
				<table>
				<tr>
					<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['hits']) && !isset($_POST['clearit']) ? ((isset($_POST['calchits'])) ? $hplvl : $_POST['hits']) : 10) . "' name='hits' /></td>
					<td style='width:50%;'><input type='submit' name='calchits' value='Calc. Hits' /></td>
				</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Ranged</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['ranged']) && !isset($_POST['clearit']) ? $_POST['ranged'] : 1) . "' name='ranged' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Prayer</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['prayer']) && !isset($_POST['clearit']) ? $_POST['prayer'] : 1) . "' name='prayer' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Magic</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['magic']) && !isset($_POST['clearit']) ? $_POST['magic'] : 1) . "' name='magic' /></td>
		</tr>
		<tr>
			<td><input type='submit' name='clearit' value='Set to Defaults' /></td>
			<td><input type='submit' name='calccomb' value='Calculate Combat' /></td>
		</tr>
		</table>";
		echo "</div></div></form>";
	break;
	case "item_id_list":
		echo "<div class='table' style='overflow:auto;height:600px;'><div class='header'><font size=5 color=#650c0c><u>Item ID List</u></font></div><div class='content'>";
		$file = array_map('rtrim',file('infrastructure/content/rawdata/item.txt'));
		for($i=0;$i<count($file);$i++){
			echo $file[$i] . "<br />";
		}
		echo "</div></div>";
	break;
	case "stat_reduction":
		echo createTable("Coming Soon" , "Stat Reduction");
	break;






case "npc_drops":




mysql_connect('localhost', 'xxx', 'xxx); //your credentials
mysql_select_db('monster'); //you credentials

//Determine the selected monster
$selectedMonster = (isset($_POST['monster'])) ? trim($_POST['monster']) : false;

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

//If a monster was selected get the data
if($selectedMonster)
{
    $id = mysql_real_escape_string($selectedMonster);
    $query = "SELECT * FROM monsters WHERE id = {$id}";
    $result = mysql_query($query) or die(mysql_error());

    if(mysql_num_rows($result)==0)
    {
        $monsterOutput = "Monster not found.";
    }
    else
    {
        $monster = mysql_fetch_assoc($result);
        //Create output to display the monster data
        $monsterOutput .= "<table border='0'>";
        $monsterOutput .= "  <tr>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Name:</font><th><td><font color=#FFFFFF>{$monster['name']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Hit Points:</font><th><td><font color=#FFFFFF>{$monster['h_points']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Attack:</font><th><td><font color=#FFFFFF>{$monster['attack']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Stamina:</font><th><td><font color=#FFFFFF>{$monster['stamina']}</font></td>\n";
        $monsterOutput .= "  </tr>";
        $monsterOutput .= "</table>";
    }
}

//Run query to get list of ALL monster names/IDs to build select list
$query = "SELECT id, name FROM monsters ORDER by name";
$result = mysql_query($query) or die(mysql_error());
//Process results into options list
$monsterOptions = '';
while($row = mysql_fetch_assoc($result))
{
    $selected = ($row['id']===$selectedMonster) ? ' selected="selected"' : '';
    $monsterOptions .= "<option value=\"{$row['id']}\"{$selected}>{$row['name']}<option>";
}





form name="menuform" method="post"
<table>
  <tr>
    <td>Monster Database</td>
  </tr>
  <tr>
    <td><center><font color=#FFFFFF>Select a monster from the list: </font></center></td>
    <td>
      <select name="monster">
        <?php echo $monsterOptions; ?>
      </select>
      <button type="submit">Submit</button>
    </td>
  </tr>
</table>
</form>
</body>
</html>
<?php echo $monsterOutput; ?>
</body>
break;




	default:

echo"
<div class='table'>
				<div class='header'>
				<img src='infrastructure/content/images/newsandannouncements.png'>
			</div>
			</div>
			";

		require 'forum/include/parser.php';
		$contentGrabThis = $db->query("SELECT * FROM topics WHERE forum_id = " . $webAnnounceId . " ORDER BY posted DESC LIMIT 0 , " . $webAnnounceLimit);
		if($db->num_rows($contentGrabThis) > 0){
			while($r = $db->fetch_assoc($contentGrabThis)){
				echo "
				<div class='table'>
					<div class='header' style='text-align:center !important;'>
						<table>
						<tr>
							<td class='td_header'>
								<a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font size=5 color=#650c0c>" . $r['subject'] ."</font></a>
							</td>
						</tr>
						</table>
					</div>
					</br>
					<div class='content'>
				";
				$countTotal = ($db->num_rows($db->query("SELECT id FROM posts WHERE topic_id = '" . $r['id'] . "'"))) - 1;
				$pullPostInfo = $db->fetch_assoc($db->query("SELECT poster_id,poster,message,hide_smilies FROM posts WHERE topic_id = '" . $r['id'] . "' ORDER BY posted ASC LIMIT 0 , 1"));
				echo filter_subject(parse_message($pullPostInfo['message'], $pullPostInfo['hide_smilies']));
				echo"
					</div>
					<div class='content' style='text-align:right;'>
					<td class='td_header' style='text-align:left;'><font color=#FFFFFF>" . date("M d Y" , $r['posted']) . "</td>
						Added by <a href='" . PUN_ROOT . "profile.php?id=" . $pullPostInfo['poster_id'] . "'><font color=#800000>" . $r['poster'] ."</font></a> • <a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font color=#800000>" . $countTotal . "</font></a> comment" . (($countTotal == 1) ? null : "s") . "</font>
					</div>
				</div>
				";
			}
		} else {
			echo createTable("No news and update content was pulled from the forum. Please make sure \$webAnnounceId has been set in ->infrastructure/generalSettings.php to the appropriate news & announcements board ID AND that you have posted at least ONE announcement in said board. <br /><br />ALSO, ensure you strictly limit the board topic creation to admins, or you run the risk of letting noobs post announcements on the front page.");
		}
	break;
}
?>
</body>
</html> 

Link to comment
Share on other sites

Notated what I fixed:  Try this:

<html>
<body>
<?php	
$mirror_list = 	array(
			0 => array('2Shared','http://www.2shared.com/file/upMd2rqD/Dunno_Client.html','December 8th 2010')
);
switch($query){

	case "highscores":
		$grabskill = isset($_GET['skill']) ? trim(strtolower($_GET['skill'])) : null;
		$search_type = isset($_GET['type']) && $_GET['type'] == 1 ? 1 : 0;
		$user_search = empty($_GET['user']) ? null : ((strlen($_GET['user']) <= 20 && $search_type == 0 || strlen($_GET['user']) <= 11 & $search_type == 1) ? $_GET['user']: null);
		echo "<form method='get' action=''><input type='hidden' name='query' value='highscores' /><input type='hidden' name='type' value='1' /><div class='table'><div class='header'><img src='infrastructure/content/images/Character Search.png'></div></br></br><div class='content'><table><tr><td style='width:30%;'><font face=Times New Roman color=#FFFFFF>Enter character name:</font></td><td style='width:50%;text-align:center;'><input type='text' name='user' maxlength='11' value='" . (($search_type == 1 && isset($user_search)) ? $user_search : null) . "' /></td><td style='text-align:right;width:20%;'><input type='submit' value='Search' /></td></tr></table></div></div></form>";
		if(isset($user_search)){
			$queryLine = ($search_type == 1) ? $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.username = '" . $db->escape($user_search) . "' LIMIT 0 , 1") : $db->query("SELECT rsca2_players.owner, rsca2_players.combat, rsca2_players.username, rsca2_players.creation_date, rsca2_players.login_date, rsca2_experience.*, users.username AS 'account_name' FROM rsca2_players JOIN users ON rsca2_players.owner = users.id JOIN rsca2_experience ON rsca2_players.user = rsca2_experience.user WHERE rsca2_players.user = '" . $db->escape($user_search) . "' LIMIT 0 , 1");
			$userdata = $db->fetch_assoc($queryLine);
			if(isset($userdata['id'])){
				echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Account Info</div><div class='content'><table><tr><td style='width:50%;'>Character Name</td><td>" . ucfirst($userdata['username']) . "</td></tr><tr><td style='width:50%;'>Account Name</td><td><a href='" . PUN_ROOT . "profile.php?id=" . $userdata['owner'] . "'>" . $userdata['account_name'] . "</a></td></tr><tr><td style='width:50%;'>Combat</td><td>" . $userdata['combat'] . "</td></tr><tr><td>Character Registered</td><td>" . date("M d Y", $userdata['creation_date']) . "</td></tr><tr><td>Last Login</td><td>" . date("M d Y", $userdata['login_date']) . "</td></tr></table></div></div>";
				echo "<div class='table'><div class='header'>" . ucfirst($userdata['username']) . "'s Skill Sheet</div><div class='content'><a style='display:block;text-align:right;' href='?query=highscores'>Go back to highscores?</a><br />";
				if($userdata['highscoreopt'] == 1){
					echo "This user has chose to hide their skills.";
				} else {
					echo "<table><tr><td style='width:50%;'>Skill</td><td style='width:25%;'>Level</td><td style='width:25%;'>Experience</td></tr>";
					for($i=0; $i < count($skills); $i++){
						echo"<tr><td><a href='?query=highscores&skill=" . $skills[$i] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[$i] . ".png' alt='X' /> " . ucfirst($skills[$i]) . "</a></td><td>" . experience_to_level($userdata['exp_' . $skills[$i]]) . "</td><td>" . number_format($userdata['exp_' . $skills[$i]]) . "</td></tr>";
					}
					echo "</table>";
				}
				echo"</div></div>";
			} else {
				echo createTable("This user does not exist. <a href='?query=highscores'>Go back to highscores?</a>");
			}
		} else {
			echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Highscores2.png'></div></br></br><div class='content'><table>";
			for($i = 1; $i < count($skills); $i++){
					echo (($i == 1) ? "\n<tr>\n" : null) . "<td><a href='?query=highscores&skill=" . $skills[($i - 1)] . "'><img src='" . $web_data['b_img'] . "highscores/" . $skills[($i - 1)] . ".png' alt='x' />" . ucfirst($skills[($i - 1)]) . "</a></td>\n" . (($i > 0 && $i % 4 == 0) ? "\n</tr>\n<tr>\n" : null);
			}
			echo "\n<td><a href='?query=highscores&skill=skill_total'> Skill Total</a></td><td><a href='?query=highscores&skill=combat'> Combat</a></td><td> </td></tr></table></div></div>\n\n";
			if(in_array($grabskill, $skills) || $grabskill == 'combat' || $grabskill == 'skill_total'){
				(int)$startRow = isset($_GET['startrow']) && $_GET['startrow'] > 0 && $_GET['startrow'] % 20 == 0 ? $_GET['startrow'] : 0;
				$HS_QueryLine = ($grabskill == 'skill_total' ? "SELECT skill_total,user,username FROM rsca2_players ORDER BY skill_total DESC" : ($grabskill == 'combat' ? "SELECT username,user,combat FROM rsca2_players ORDER BY combat DESC" : "SELECT DISTINCT(rsca2_experience.user), rsca2_experience.highscoreopt, rsca2_experience.exp_" . $grabskill . ", rsca2_players.username FROM rsca2_experience JOIN rsca2_players ON rsca2_experience.user = rsca2_players.user WHERE rsca2_experience.highscoreopt = 0 AND rsca2_experience.exp_" . $grabskill . " > 0 ORDER BY rsca2_experience.exp_" . $grabskill . " DESC"));
				$generateHSList = $db->query($HS_QueryLine . " LIMIT " . $startRow . ", 20");
				echo "<div class='table'><div class='header'><table><tr><td style='width:70%;text-align:left;'>Skill Table for " . str_replace("_", " ", ucfirst($grabskill)) . "</td><td style='width:30%;text-align:right;'><a href='?query=highscores'>Close</a></td></tr></table></div><div class='content'>";
				if($db->num_rows($generateHSList) == 0){
					echo "No results found for this particular skill.";
				} else {
					$i = $startRow + 1;
					$getTotalRows = $db->num_rows($db->query($HS_QueryLine));
					$nextUp = (($startRow - 20) < 0) ? 0 : $startRow - 20;
					$nextDown = (($startRow + 20) > $getTotalRows) ? 0 : $startRow + 20;
					echo "<table><tr><td style='width:5%;'> </td><td style='width:55%;'>Username</td>" . ($grabskill == 'skill_total' ? "<td style='width:20%;'>Skill total</td><td> </td>" : ($grabskill == 'combat' ? "<td style='width:20%;'>Combat</td><td> </td>" : "<td style='width:20%;'>Level</td><td style='width:20%;'>Experience</td>")) . "</tr><tr><td colspan='4' style='height:22px;text-align:right;'>" . (($nextUp == 0 && $nextDown == 20 || $nextUp == 0 && $nextDown == 0) ? " " : "<a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextUp . "'><img src='" . $web_data['b_img'] . "/arrow_up.png' alt='^' /></a>") . "</td></tr>";
					while($r = $db->fetch_assoc($generateHSList)){
						echo "<tr><td>" . (($i <= 5) ? "<span style='font-weight:bold;'>" . $i . "</span>" : $i) . "</td><td><a href='?query=highscores&user=" . $r['user'] . "'>" . ucfirst($r['username']) . "</a></td> " . ($grabskill == 'skill_total' ? "<td>" . number_format($r['skill_total']) . "</td><td> </td>" : ($grabskill == 'combat' ? "<td>" . $r['combat'] . "</td><td> </td>" : "<td>" . experience_to_level($r['exp_' . $grabskill]) . "</td><td>" . number_format($r['exp_' . $grabskill]) . "</td>")) .  "</tr>";
						$i ++;
					}
					echo (($getTotalRows > 20) ? "<tr><td colspan='4' style='text-align:right;'><a href='?query=highscores&skill=" . $grabskill . "&startrow=" . $nextDown . "'><img src='" . $web_data['b_img'] . "/arrow_down.png' alt='V' /></a></td></tr>" : null) . "</table>";
				}
				echo "</div></div>";
			}
		}
	break;
	case "players_online":
		$getMembers = $db->query("SELECT * FROM rsca2_players WHERE loggedin = 1 ORDER BY group_id DESC");
		$countMembers = $db->num_rows($getMembers);
		echo "<div class='table'><div class='header'>Players Online (" . $countMembers . ")</div><div class='content'>";
		if($countMembers > 0){
			$i = 0;

			while($doQuery = $db->fetch_assoc($getMembers)){
				switch($doQuery['group_id']){
					case 3: 
						echo "<img src='" . $web_data['b_img'] . "/mod/pmd.png' alt='[PMod]' />";
					break;
					case 2: 
						echo "<img src='" . $web_data['b_img'] . "/mod/mod.png' alt='[Mod]' />";
					break;
					case 1: 
						echo "<img src='" . $web_data['b_img'] . "/mod/adm.png' alt='[admin]' />";
					break;
					default: break;
				}
				echo "<a href='?query=highscores&lookup=" . $doQuery['user'] . "'>" . $doQuery['username'] . "</a>";
				if(($i + 1) == $countMembers){} else { echo ", "; }
				$i++;
			}
		} else {
			echo "There is currently no registered users logged in game.";
		}
		echo "</div></div>";
	break;
	case "cms":
		if($pun_user['is_guest']){
			echo $mustBeLoggedIn;
		} else {
			$totalchars = $db->num_rows($db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'"));
			$switchAct = isset($_GET['act']) ? strtolower(trim($_GET['act'])) : null;
			$cmsPre = "<div class='table'><div class='header'>CMS Response</div><div class='content'>";
			$cmsSuf = "</div></div>";
			echo "<div id='characterMS'>
			<div class='table'>
			<div class='header'><img src='infrastructure/content/images/Character Management System.png'></div>
			<div class='content'>
			</br>
			</br>
			</br>
				<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou are limited to <font size=3 face=Times New Roman color=#650c0c>10</font> characters per forum account.</font></center>
				<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou will be unable to multi-log with 2 characters on the same forum account.</font></center>";
				if(empty($pun_user['del_pin']) && $switchAct != 'set_pin'){
					echo "<center><font size=4 face=Times New Roman color=#650c0c>Y</font><font size=3 face=Times New Roman color=#FFFFFF>ou have not yet set your character deletion pin, would like to set one</font> <a href='?query=cms&act=set_pin'>now</a>?</center>";
				}

				if($switchAct != 'addnew' && $totalchars < 10){
				echo "
					<br /><br /><center><font size=4 face=Times New Roman color=#650c0c>C</font><font size=3 face=Times New Roman color=#FFFFFF>lick</font> <a href='?query=cms&act=addnew'>here</a><font size=3 face=Times New Roman color=#FFFFFF> if you wish to add a new character.</font>
				";
			}
			if($totalchars >= 10){
				echo "<br /><br />Sorry but you currently have 10 characters and can not add more. You must either delete one or make a new forum account.";
			}
			echo "</div></div>";
			switch($switchAct){
				case "set_pin":
					if(!empty($pun_user['del_pin'])){
						echo createTable("You have already set a PIN.");
					} else {
						if(isset($_POST['set_pin'])){
							$pin1 = isset($_POST['pin_1']) ? (is_numeric($_POST['pin_1']) ? $_POST['pin_1'] : null) : null;
							$pin2 = isset($_POST['pin_2']) ? (is_numeric($_POST['pin_2']) ? $_POST['pin_2'] : null) : null;
							if($pin1 == null || $pin2 == null){
								echo createTable("You need to fill in both pin inputs, and ensure that the pin you entered is numeric.");
							} else if ( strlen($pin1) != 4 || strlen($pin2) != 4){
								echo createTable("Please ensure that your pin is 4 characters in length.");
							} else if ($pin1 != $pin2){
								echo createTable("Please ensure that your pins match eachother.");
							} else {
								$set_pin = $db->query("UPDATE users SET del_pin = '" . $pin1 . "' WHERE id = '" . $pun_user['id'] . "'");
								echo createTable("You have successfully set your character management pin. <a href='?query=cms'>Refreshing...</a><meta http-equiv='refresh' content='1;url=?query=cms' />", "Success");
							}
						}
						echo "
							<form method='post' action='?query=cms&act=set_pin'>
							<div class='table'>
								<div class='header'><img src='infrastructure/content/images/Set Deletion Pin.png'></div>
								<div class='content'>
									<table>
									<tr>
										<td style='width:20%;'>Write Pin</td>
										<td style='width:15%;'><input type='password' size='4' maxlength='4' name='pin_1' value='" . (isset($_POST['pin_1']) ? $_POST['pin_1'] : null) . "' /></td>
										<td style='width:65%;vertical-align:top;' rowspan='3'>
											If you are going to set a character deletion pin, please ensure that you can REMEMBER it, as this will become always required in order to delete characters.
										</td>
									</tr>
									<tr>
										<td>Confirm Pin</td>
										<td><input type='password' size='4' maxlength='4' name='pin_2' value='" . (isset($_POST['pin_2']) ? $_POST['pin_2'] : null) . "' /></td>
									</tr>
									<tr>
										<td>
											<input type='submit' name='set_pin' value='Set My Pin' />
										</td>
										<td>
											<a href='?query=cms'>Cancel</a>
										</td>
									</tr>
									</table>
								</div>
							</div>
							</form>
						";
					}
				break;
				case "opt":
					$cleanChar = (is_numeric($_GET['char']) && $_GET['char'] > 0) ? trim($_GET['char']) : null;
					if(isset($cleanChar)){
						$findInfo = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($cleanChar) . "'"));
						if($findInfo['owner'] == $pun_user['id']){
							$expSelect = $db->fetch_assoc($db->query("SELECT * FROM rsca2_experience WHERE user = '" . $findInfo['user'] . "'"));
							if($expSelect['highscoreopt'] == 0){
								$db->query("UPDATE rsca2_experience SET highscoreopt = '1' WHERE user = '" . $db->escape($cleanChar) . "'") or die();
								#echo "Setting to hide";
							} else {
								#echo "Setting to show";
								$db->query("UPDATE rsca2_experience SET highscoreopt = '0' WHERE user = '" . $db->escape($cleanChar) . "'") or die();
							}
						}
					}
				break;
				case "deletecharacter":
					$grab_char_id = isset($_GET['char']) ? $_GET['char'] : null;
					if(is_numeric($grab_char_id)){
						$checkdata = $db->fetch_assoc($db->query("SELECT * FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'"));
						if($checkdata['owner'] == $pun_user['id']){
							if(isset($_POST['deletechar'])){
								if(!empty($pun_user['del_pin']) && $_POST['deletion_pin'] != $pun_user['del_pin']){
									echo createTable("The pin you entered was incorrect... <meta http-equiv='refresh' content='1;url=?query=cms'><a href='?query=cms'>refreshing momentarily</a>.");
									return;
								}
								$db->query("DELETE FROM rsca2_players WHERE user = '" . $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_curstats WHERE user = '" . $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_experience WHERE user = '" .  $db->escape($grab_char_id) . "'");
								$db->query("DELETE FROM rsca2_invitems WHERE user = '" .  $db->escape($grab_char_id). "'");
								$db->query("DELETE FROM rsca2_logins WHERE user = '" .  $db->escape($grab_char_id) . "'");
								#echo $cmsPre . "<meta http-equiv='refresh' content='1;url=?query=cms'>Your character has been successfully deleted, <a href='?query=cms'>refreshing momentarily</a>." . $cmsSuf;
							} else {
							echo "
								<form method='post'>
									<div class='table'><div class='header'>Delete confirmation for '".$checkdata['username']."'</div>
									<div class='content'>
										Are you sure you wish to delete this character? This action is totally irreversible! <br />
										<table>
							";
							if(!empty($pun_user['del_pin'])){
								echo "
										<tr>
											<td style='width:50%;'>
												Enter Deletion Pin:
											</td>
											<td style='width:50%;text-align:right;'>
												<input type='password' name='deletion_pin' value='' size='4' maxlength='4' />
											</td>
										</tr>
								";
							}
							echo"
										<tr>
											<td style='width:50%;'>
												<input type='submit' value='Delete Character' name='deletechar' />
											</td>
											<td style='text-align:right;'>
												<a href='?query=cms'>Cancel</a>
											</td>
										</tr>
										</table>
									</div>
									</div>
								</form>
							";
							}
						} else {
							echo $cmsPre . "This is not your character." . $cmsSuf;
						}
					} else {
						echo $cmsPre . "Invalid Character ID." . $cmsSuf;
					}
				break;
				default:
				break;
			}

			echo "
			<div class='table'>
			<div class='header'><img src='infrastructure/content/images/My Existing Characters.png'></div>
			<div class='content'>";
			$fetchCharacters = $db->query("SELECT * FROM rsca2_players WHERE owner = '" . $pun_user['id'] . "'");
			if($db->num_rows($fetchCharacters) > 0){

				echo "
				<table id='cmsTable' style='width:100%;'>
				<tr id='cmsHeaders'>
				<br></br>

					<td style='width:35%;'><font size=5 face=Times New Roman color=#FFFFFF>Character</font></td>
					<td style='width:20%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Password</font></td>
					<td style='width:35%;text-align:center;'><font size=5 face=Times New Roman color=#FFFFFF>Highscore Opt</font></td>
					<td style='width:10%;text-align:right;'><font size=5 face=Times New Roman color=#FFFFFF>Delete</font></td>
				</tr>
				";
				while($r = $db->fetch_assoc($fetchCharacters)){
					$optCheck = $db->fetch_assoc($db->query("SELECT highscoreopt FROM rsca2_experience WHERE user = '" . $r['user'] . "'"));
					echo "<tr><td><a href='?query=highscores&lookup=" . $r['username'] . "&s_type=1'>" . $r['username'] . "</a></td><td style='text-align:center;'><a href='?query=cms&act=changepass&char=".$r['user']."'>Change</a></td><td style='text-align:center;'>" . (($optCheck['highscoreopt'] == 0) ? "<a href='?query=cms&char=" . $r['user'] . "&act=opt'>Hide</a>" : "<a href='?query=cms&act=opt&char=" . $r['user'] . "'>Show</a>") . "</td><td style='text-align:right;'><a href='?query=cms&act=deletecharacter&char=".$r['user']."'>X</a></td></tr>";
				}
				echo "
				</table>
				";
			} else {
				echo "You have not yet <a href='?query=cms&act=addnew'>added a character</a> to this account.";
			}
			echo "
			</div></div></div>
			";
		}
	break;

	case "login_page":
		require('quickLogin.php');
	break;

	case "rules":
		echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Rules.png'></div><div class='content'>";

		$file = array_map('rtrim',file('infrastructure/content/rawdata/rules2.txt'));
		for($i=0;$i<count($file);$i++){
			echo str_replace("\$SERVER_NAME\$", $web_primary_name, $file[$i]) . "<br />";
		}
		echo "</div></div>";
	break;
	case "combat_calculator":
		if(isset($_POST['calccomb']) || isset($_POST['calchits'])){
			$attack = isset($_POST['attack']) && is_numeric($_POST['attack']) && $_POST['attack'] > 0 && strlen($_POST['attack']) <= 2 ? $_POST['attack'] : null;
			$defense = isset($_POST['defense']) && is_numeric($_POST['defense']) && $_POST['defense'] > 0 && strlen($_POST['defense']) <= 2 ? $_POST['defense'] : null;
			$strength = isset($_POST['strength']) && is_numeric($_POST['strength']) && $_POST['strength'] > 0 && strlen($_POST['strength']) <= 2 ? $_POST['strength'] : null;
			$hits = isset($_POST['hits']) && is_numeric($_POST['hits']) && $_POST['hits'] > 0 && strlen($_POST['hits']) <= 2 ? $_POST['hits'] : null;
			$ranged = isset($_POST['ranged']) && is_numeric($_POST['ranged']) && $_POST['ranged'] > 0 && strlen($_POST['ranged']) <= 2 ? $_POST['ranged'] : null;
			$magic = isset($_POST['magic']) && is_numeric($_POST['magic']) && $_POST['magic'] > 0 && strlen($_POST['magic']) <= 2 ? $_POST['magic'] : null;
			$prayer = isset($_POST['prayer']) && is_numeric($_POST['prayer']) && $_POST['prayer'] > 0 && strlen($_POST['prayer']) <= 2 ? $_POST['prayer'] : null;
			/* CALC HITS */
			$totalexp = ($exps[($attack - 2)] + $exps[($defense - 2)] + $exps[($strength - 2)]);
			$divideexp = floor($totalexp / 3) + 1200;
			$convertexp = experience_to_level($divideexp);
			$hplvl = $convertexp;
			/* CALC COMB */
			if(!isset($_POST['calchits'])){
				echo "<div class='table'><div class='header'><img src='infrastructure/content/images/Calculated Results.png'></div></br></br><div class='content'>";
				if($attack == null || $defense == null || $strength == null || $hits == null || $ranged == null || $magic == null || $prayer == null){
					echo "You either left a field blank or attempted to add bad data.";
				} else {
					$calcatkdefstr = (($attack + $defense + $strength + $hits) * .25);
					$calcmagicprayer = ($magic + $prayer) * 0.125;

					if(($attack + $strength) < ($ranged * 1.5)){
						$defhits = ($defense + $hits) * 0.25;
						$fixrange = $ranged * 0.375;
						$newcb = $defhits + $fixrange + $calcmagicprayer;
						$base = 0;
					} else {
						$base = 1;
						$newcb = $calcatkdefstr + $calcmagicprayer;
					}
					$nextcb = floor(($newcb) + 1) - $newcb;
					$nextFightLevel = (floor(($nextcb) / 0.25)) - 1;
					$nextPMLevel = (floor(($nextcb) / 0.125)) - 1;
					$nextRangeLevel = (floor(($nextcb) / 0.375));
					$atkDefAddTo = floor($ranged * 1.5);
					$nextFightLevel = $nextFightLevel < 0 ? 0 : $nextFightLevel;
					$nextPMLevel = $nextPMLevel < 0 ? 0 : $nextPMLevel;
					$nextRangeLevel = $nextRangeLevel < 0 ? 0 : $nextRangeLevel;
					echo "
						<table>
						<tr>
							<td style='width:40%;'>Combat Level</td>
							<td style='width:60%;'><span class='highlighter'>" . $newcb . "</span></td>
						</tr>
						<tr>
							<td style='width:40%;'>Character Base</td>
							<td style='width:60%;'>" . ($base == 0 ? "Ranger" : "Fighter") . "</td>
						</tr>
					";if($hits < 10 || $newcb < 3.5){
					echo "<tr><td valign='top'>Extra Notes</td><td>Administrative character. <br />[ Detected < 10 hp || cblvl < 3.5]</td></tr>"; }
					if($base == 0){
						echo "
							<tr>
								<td valign='top'>You can max out with:</td>
								<td>" . $nextRangeLevel . " more ranged level(s).<br />" . $nextFightLevel . " more defense or hits level(s).<br /> " . $nextPMLevel . " more magic or prayer level(s).
								<br /><br />Because you are primarily a ranger, if you DO NOT raise your ranged level, your attack and strength will have NO effect on your combat level until they add to " . $atkDefAddTo . "


								</td>
							</tr>
						";
					} else {
						echo "
							<tr>
								<td valign='top'>You can max out with:</td>
								<td>" . $nextFightLevel . " more attack, defense, or strength level(s). <br />" . $nextPMLevel . " more magic or prayer level(s).</td>
							</tr>
						";
					}
					echo "
						</table>
					";
				}
				echo "</div></div>";
			}
		}
		echo "
		<form method='post'><div class='table'><div class='header'><img src='infrastructure/content/images/Combat Calculator2.png'></div></br></br><div class='content'>
		<input type='hidden' name='query' value='combat_calculator' />
		<table style='width:75%;margin:auto;'>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Attack</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['attack']) && !isset($_POST['clearit']) ? $_POST['attack'] : 1) . "' name='attack' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Defense</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['defense']) && !isset($_POST['clearit']) ? $_POST['defense'] : 1) . "' name='defense' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Strength</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['strength']) && !isset($_POST['clearit']) ? $_POST['strength'] : 1) . "' name='strength' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Hits</font></td>
			<td style='width:50%;'>
				<table>
				<tr>
					<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['hits']) && !isset($_POST['clearit']) ? ((isset($_POST['calchits'])) ? $hplvl : $_POST['hits']) : 10) . "' name='hits' /></td>
					<td style='width:50%;'><input type='submit' name='calchits' value='Calc. Hits' /></td>
				</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Ranged</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['ranged']) && !isset($_POST['clearit']) ? $_POST['ranged'] : 1) . "' name='ranged' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Prayer</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['prayer']) && !isset($_POST['clearit']) ? $_POST['prayer'] : 1) . "' name='prayer' /></td>
		</tr>
		<tr>
			<td style='width:50%;'><font color=#FFFFFF>Magic</font></td>
			<td style='width:50%;'><input type='text' maxlength='2' size='2' value='" . (isset($_POST['magic']) && !isset($_POST['clearit']) ? $_POST['magic'] : 1) . "' name='magic' /></td>
		</tr>
		<tr>
			<td><input type='submit' name='clearit' value='Set to Defaults' /></td>
			<td><input type='submit' name='calccomb' value='Calculate Combat' /></td>
		</tr>
		</table>";
		echo "</div></div></form>";
	break;
	case "item_id_list":
		echo "<div class='table' style='overflow:auto;height:600px;'><div class='header'><font size=5 color=#650c0c><u>Item ID List</u></font></div><div class='content'>";
		$file = array_map('rtrim',file('infrastructure/content/rawdata/item.txt'));
		for($i=0;$i<count($file);$i++){
			echo $file[$i] . "<br />";
		}
		echo "</div></div>";
	break;
	case "stat_reduction":
		echo createTable("Coming Soon" , "Stat Reduction");
	break;






case "npc_drops":




mysql_connect('localhost', 'xxx', 'xxx'); //your credentials //missing a single quote] *JCBONES
mysql_select_db('monster'); //you credentials

//Determine the selected monster
$selectedMonster = (isset($_POST['monster'])) ? trim($_POST['monster']) : false;

//Variable to hold the output of the seelcted monster
$monsterOutput = '';

//If a monster was selected get the data
if($selectedMonster)
{
    $id = mysql_real_escape_string($selectedMonster);
    $query = "SELECT * FROM monsters WHERE id = {$id}";
    $result = mysql_query($query) or die(mysql_error());

    if(mysql_num_rows($result)==0)
    {
        $monsterOutput = "Monster not found.";
    }
    else
    {
        $monster = mysql_fetch_assoc($result);
        //Create output to display the monster data
        $monsterOutput .= "<table border='0'>";
        $monsterOutput .= "  <tr>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Name:</font><th><td><font color=#FFFFFF>{$monster['name']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Hit Points:</font><th><td><font color=#FFFFFF>{$monster['h_points']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Attack:</font><th><td><font color=#FFFFFF>{$monster['attack']}</font></td>\n";
        $monsterOutput .= "    <th><font color=#FFFFFF>Stamina:</font><th><td><font color=#FFFFFF>{$monster['stamina']}</font></td>\n";
        $monsterOutput .= "  </tr>";
        $monsterOutput .= "</table>";
    }
}

//Run query to get list of ALL monster names/IDs to build select list
$query = "SELECT id, name FROM monsters ORDER by name";
$result = mysql_query($query) or die(mysql_error());
//Process results into options list
$monsterOptions = '';
while($row = mysql_fetch_assoc($result))
{
    $selected = ($row['id']===$selectedMonster) ? ' selected="selected"' : '';
    $monsterOptions .= "<option value=\"{$row['id']}\"{$selected}>{$row['name']}<option>";
}

//closed PHP: JCBONES
?>


<form name="menuform" method="post"> <!--Form not properly created JCBONES-->
<table>
  <tr>
    <td>Monster Database</td>
  </tr>
  <tr>
    <td><center><font color=#FFFFFF>Select a monster from the list: </font></center></td>
    <td>
      <select name="monster">
        <?php echo $monsterOptions; ?>
      </select>
      <button type="submit">Submit</button>
    </td>
  </tr>
</table>
</form>
</body>
</html>
<?php echo $monsterOutput; ?>
</body>
<?php //reopened PHP. JCBONES
break;




	default:

echo"
<div class='table'>
				<div class='header'>
				<img src='infrastructure/content/images/newsandannouncements.png'>
			</div>
			</div>
			";

		require 'forum/include/parser.php';
		$contentGrabThis = $db->query("SELECT * FROM topics WHERE forum_id = " . $webAnnounceId . " ORDER BY posted DESC LIMIT 0 , " . $webAnnounceLimit);
		if($db->num_rows($contentGrabThis) > 0){
			while($r = $db->fetch_assoc($contentGrabThis)){
				echo "
				<div class='table'>
					<div class='header' style='text-align:center !important;'>
						<table>
						<tr>
							<td class='td_header'>
								<a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font size=5 color=#650c0c>" . $r['subject'] ."</font></a>
							</td>
						</tr>
						</table>
					</div>
					</br>
					<div class='content'>
				";
				$countTotal = ($db->num_rows($db->query("SELECT id FROM posts WHERE topic_id = '" . $r['id'] . "'"))) - 1;
				$pullPostInfo = $db->fetch_assoc($db->query("SELECT poster_id,poster,message,hide_smilies FROM posts WHERE topic_id = '" . $r['id'] . "' ORDER BY posted ASC LIMIT 0 , 1"));
				echo filter_subject(parse_message($pullPostInfo['message'], $pullPostInfo['hide_smilies']));
				echo"
					</div>
					<div class='content' style='text-align:right;'>
					<td class='td_header' style='text-align:left;'><font color=#FFFFFF>" . date("M d Y" , $r['posted']) . "</td>
						Added by <a href='" . PUN_ROOT . "profile.php?id=" . $pullPostInfo['poster_id'] . "'><font color=#800000>" . $r['poster'] ."</font></a> • <a href='" . PUN_ROOT . "viewtopic.php?id=" . $r['id'] . "'><font color=#800000>" . $countTotal . "</font></a> comment" . (($countTotal == 1) ? null : "s") . "</font>
					</div>
				</div>
				";
			}
		} else {
			echo createTable("No news and update content was pulled from the forum. Please make sure \$webAnnounceId has been set in ->infrastructure/generalSettings.php to the appropriate news & announcements board ID AND that you have posted at least ONE announcement in said board. <br /><br />ALSO, ensure you strictly limit the board topic creation to admins, or you run the risk of letting noobs post announcements on the front page.");
		}
	break;
}
?>
</body>
</html> 

Link to comment
Share on other sites

@Mike D.

 

This is slightly off topic, but I would highly suggest that you consider taking a more modularized approach to your coding. It makes creating/debugging/maintaining/fixing so much easier. Having a file with 1400+ lines of code makes this more complicated than it needs to be. That is primarily why I chose not to respond further in this thread - it was going to take me more time to debug the issue due to the complicated structure than was worthwhile for me. As a quick example of one easy change you could make, I see that there is a switch() statement used to decide what the page is supposed to do. You should make this script your "controller" script to determine what actions to perform and then have separate scripts to perform those action. In other words, use the switch() statement in this script but then instead of having a bunch of code under each case statement put that code into a sepaate file and include() it under the case statement.

 

Here is a very brief example of how I would make that main switch statement look. Also, you have a "default" for the switch statement that doesn't do anything. I typically set the default action for my pages to some benign action - such as a "display" type action to make sure the page never "fails". But, there is something to be said for having the page display empty if there is an unexpected action request as it could be a visual indicator that you forgot to handle a particular action. Lastly, you are using the variable $query as the value for the switch. I would suggest a different variable name ($action comes to mind) since $query is typically used as a variable to hold DB queries. Basically, give your variables meaningful names that someone can identify what it likely contains without reading all the code. In fact, I even go so far in some cases as to add a descriptor to my variables to identify the type of data it contains. E.g.: $userListAry vs. $userListStr

 

Anyway here is the example

    switch($query)
    {
        case "players_online":
            include('_show_players_online.php');
            break;

        case "cms":
            include('_show_cms.php');
            break;

        case "opt":
            include('_show_opt.php');
            break;

        case "deletecharacter":
            include('_show_deletecharacter.php');
            break;

        case "highscores":
        default:
            include('_show_highscores.php')
            break;
    }

Link to comment
Share on other sites

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.