Thanks sniko for the update, im posting it hereunder as i think most would like to see it here before downloading, if you don't mind!
estateAgent.php
<?php
include_once('globals.php');
echo '<h3>Estate Agent</h3>';
if(!$_GET)
{
return index();
}
switch($_GET['p'])
{
case 'buy' : buy(); break;
case 'viewHouse' : viewHouse(); break;
default: index();
}
function index()
{
global $db, $ir, $h;
$house = $db->fetch_row( $db->query("SELECT `hNAME` FROM `houses` WHERE `hWILL`=". $ir['maxwill'] ." ") );
echo '[b]Your current Property:[/b] ', $house["hNAME"] ,'
[i]Welcome to the estate agent, ', $ir["username"] ,'. Here you can view the properties avaliable and purchase them.[/i]
';
$get = $db->query("SELECT `hNAME`,`hID` FROM `houses` ORDER BY `hWILL`,`hNAME` ASC");
while($r = $db->fetch_row($get))
{
echo "[i]". $r['hNAME'] ."[/i] » [url='?p=viewHouse&id=".$r[']View the house[/url]
";
}
exit( $h->endpage() );
}
function viewHouse()
{
global $db, $ir, $h;
$_GET['id'] = (isset($_GET['id']) & abs( is_numeric($_GET['id'])) ) ? $_GET['id'] : FALSE;
if($_GET['id'] == FALSE OR $_GET['id'] <= 0)
{
echo "We aren't selling this house at the moment!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
$exist = $db->query("SELECT `hNAME`,`hWILL`,`hPRICE` FROM `houses` WHERE `hID`=". $_GET['id'] ." ");
if($db->num_rows( $exist ) == 0)
{
echo "We aren't selling this house at the moment!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
$r = $db->fetch_row($exist);
echo "<h4> » [b]Viewing:[/b] {$r['hNAME']} </h4>
<div style='width: 500px; padding: 5px; background: #D4D4D4; border: 1px solid #000000; text-align: center;'>
[img=housepic/{$r[]
</div>
";
$color = ($ir['money'] >= $r['hPRICE']) ? "green" : "red";
echo "<font size='34pt' color='".$color."'>$".number_format($r['hPRICE'])."</font>
[b]House Statistics[/b]
Amount owned: ". $q = $db->num_rows( $db->query("SELECT `userid` FROM `users` WHERE `maxwill`={$r['hWILL']}") ) ."
Will Increase: ". $will = ($r['hWILL'] / 100) * $ir['maxwill'] ."%";
if($color == "green" AND $ir['maxwill'] < $r['hWILL'])
{
echo "
<font size='34pt'>» [url='?p=buy&id=".$_GET[']Purchase[/url]";
}
exit( $h->endpage() );
}
function buy()
{
global $h, $db, $userid, $ir;
$_GET['id'] = (isset($_GET['id']) & abs( is_numeric($_GET['id'])) ) ? $_GET['id'] : FALSE;
if($_GET['id'] == FALSE OR $_GET['id'] <= 0)
{
echo "We aren't selling this house at the moment!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
$exist = $db->query("SELECT `hNAME`,`hPRICE`,`hWILL` FROM `houses` WHERE `hID`=". $_GET['id'] ." ");
if($db->num_rows( $exist ) == 0)
{
echo "We aren't selling this house at the moment!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
$r = $db->fetch_row($exist);
if($ir['money'] < $r['hPRICE'])
{
echo "You don't have enough money at the moment!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
if($ir['maxwill'] > $r['hWILL'])
{
echo "You don't want to get a smaller property do you?!
» [url='?p=index']Back to Estate Agent[/url]";
exit( $h->endpage() );
}
echo "Congratulations, you have just purchased a {$r['hNAME']} for $".number_format($r['hPRICE'])."!
» [url='index.php']Back Home[/url]";
$db->query("UPDATE `users` SET `money`=`money`-{$r['hPRICE']},`maxwill`={$r['hWILL']} WHERE `userid`=$userid");
exit($h->endpage());
}
?>
Instructions
Create a new directory called housepic
Upload the house images to that directory
[house name from database].png
Any queries?
IM: [email]
[email protected][/email]
EMAIL: [email]
[email protected][/email]
[url]www.delphac.com[/url] || sniko
cheers :thumbup: