• 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 PHP House Owner and Pricelist for XML Servers

GOD Rox

New Member
Joined
Aug 31, 2010
Messages
8
Reaction score
2
Hello,

I need help with my houses.php script. I'm hosting a website based on Nicaw ACC (XML) and a Tibia 7.6 XML Server.

houses.php

PHP:
// houses.php


<?php

include ("config.php");
include ("functions.php");
$ptitle="Houses - $cfg[server_name]";
include ("layout/overall/header.php");;

if (!is_file($cfg['dirdata'].$cfg['house_file']))
    throw new Exception('House file not found: '.$cfg['dirdata'].$cfg['house_file']);
?>

<h2 style=text-align:center;>House List</h2>

<div style="height: 500px; overflow: auto; margin: 10px;">
<table>
<tr class="color0">
<td><b>House</b></td>
<td><b>Owner</b></td>
<td><b>SquareMeter</b></td>
<td><b>Price</b></td>
</tr>

<?php
// loads houses.xml in data folder
$HousesXML = simplexml_load_file($cfg['dirdata'].$cfg['house_file']);
    $houses[(int)$row['id']] = $row['name'];

foreach ($HousesXML->house as $house){
    $i++;
    // Calculate Price for House (1 squaremeter = 10 Crystal Coins)
    $price = (int)($house['size']) * 10;
    $list.= '<tr>
                <td>'.htmlspecialchars($house['name']).'</td>
                 <td>'.htmlspecialchars($house['owner']).'</td>
                 <td>'.$house['size'].'</td>
                 <td>'.$price.' cc</td>
             </tr>'."\r\n";
}
echo $list;

?>
</table>
<?php include('layout/overall/footer.php');?>

houses.xml

XML:
<houses>

    <house name="City Villa" frontdoorx="136" frontdoory="100" frontdoorz="7" donator="1" size="10">
        <tiles fromx="123" fromy="101" fromz="7" tox="130" toy="111" toz="7"></tiles>
        <tiles fromx="131" fromy="101" fromz="7" tox="137" toy="106" toz="7"></tiles>
        <tiles fromx="126" fromy="101" fromz="6" tox="138" toy="108" toz="6"></tiles>
    </house>

House Example with Owner:

XML:
<?xml version="1.0"?>
<house><frontdoor x="136" y="100" z="7"/><owner name="Test"/></house>


Every house is saved in the folder data/houses with an own xml file. How do I get all owner names from all xml files
in data/houses by using the houses.php script to make a house list on my website?

I attached a picture as an example of my houselist on my website.


I hope you can help me
 

Attachments

Back
Top