• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[PHP]- Quest table for Nicaw

RealSoft

Banned User
Joined
Feb 3, 2009
Messages
4,381
Reaction score
92
Location
There I sleep
Hello. I would like someone to help me!

Rep++ and some other reward will be given!

Ok, this is the deal..
I'm going to start store my quests in database, now I'm not enought PHP Geek to fix a proper table for it.. I tried some but it didn't go well at all <.< hah..

Anyhow..

I want this one to sort out by "name".
it should list all these
Name - Location - level - reward, list everyone with "hidden_id = 0"
table name "world_quest"

I would like it to be samiliar to a house-list,
Here's a Script of the house list, and would love if someone could make it fit for the info I gave above!

PHP:
<?php 
include ("include.inc.php");
$ptitle="Houses - $cfg[server_name]";
include ("header.inc.php");
if (!is_file($cfg['dirdata'].$cfg['house_file']))
	throw new Exception('House file not found: '.$cfg['dirdata'].$cfg['house_file']);
?>
<div id="content">
<div class="top">Houses</div>
<div class="mid">
<div style="height: 500px; overflow: auto; margin: 10px;">
<table>
<tr class="color0"><td width="35%"><b>House</b></td><td width="25%"><b>Location</b></td><td width="25%"><b>Owner</b></td><td><b>Size</b></td><td><b>Rent</b></td></tr>
<?php 
$HousesXML = simplexml_load_file($cfg['dirdata'].$cfg['house_file']);
$MySQL = new SQL();
$MySQL->myQuery('SELECT `players`.`name`, `houses`.`id` FROM `players`, `houses` WHERE `houses`.`owner` = `players`.`id`;');
if ($MySQL->failed())
	throw new Exception('SQL query failed:<br/>'.$SQL->getError());
while ($row = $MySQL->fetch_array()){
	$houses[(int)$row['id']] = $row['name'];
}
foreach ($HousesXML->house as $house){
	$i++;
	$list.= '<tr '.getStyle($i).'><td>'.htmlspecialchars($house['name']).'</td><td>'.htmlspecialchars($cfg['temple'][(int)$house['townid']]['name']).'</td><td>'.$houses[(int)$house['houseid']].'</td><td>'.$house['size'].'</td><td>'.$house['rent'].'</td></tr>'."\r\n";
}
echo $list;

?>
</table>
</div>
</div>
<div class="bot"></div>
</div>
<?php include('footer.inc.php');?>


Gogo tigers! :p
 
PHP:
   <?php 
include ("include.inc.php");
$ptitle="Quests - $cfg[server_name]";
include ("header.inc.php");
?>
<div id="content">
<div class="top">Quests</div>
<div class="mid">
<div style="height: 500px; overflow: auto; margin: 10px;">
<table>
<tr class="color0"><td width="35%"><b>Quest</b></td><td width="25%"><b>Location</b></td><td width="25%"><b>Level</b></td><td><b>Reward</b></td></tr>
<?php 
$MySQL = new SQL();
$MySQL->myQuery('SELECT `quest_name`, `quest_level`, `quest_reward`, `quest_location` FROM `world_quests` WHERE `hidden_id` = 0;');
if ($MySQL->failed())
    throw new Exception('SQL query failed:<br/>'.$SQL->getError());
$i = 0;
while ($row = $MySQL->fetch_array()){
$i++;
    $list.= '<tr '.getStyle($i).'><td>'.htmlspecialchars($row['quest_name']).'</td><td>'.htmlspecialchars($row['quest_location']).'</td><td>'.$row['quest_level'].'</td><td>'.htmlspecialchars($row['quest_reward']).'</td></tr>'."\r\n";
}
echo $list;

?>
</table>
</div>
</div>
<div class="bot"></div>
</div>
<?php include('footer.inc.php');?>

Code:
CREATE TABLE `world_quests` (
`hidden_id` TINYINT( 1 ) NOT NULL DEFAULT '0' COMMENT 'Hide it?',
`quest_name` VARCHAR( 64 ) NOT NULL ,
`quest_location` VARCHAR( 64 ) NOT NULL ,
`quest_level` INT( 5 ) NOT NULL ,
`quest_reward` TEXT NOT NULL
) ENGINE = MYISAM ;
 
Back
Top