I'm not the best at coding and now I ran into a problem. I worked for 2 weeks to make it for the houses/properties. When buying a property you can view it's picture. So basically I'm wanting to convert that script and use it on items as well, but I ran out of ideas how to do it. Basically how it works is that you make a new folder, and add there pics in PNG format with the house's name, the image area searches for that pic in that folder by the name of the house your viewing and it loads it.
It's really easy to use and add new images to my game, that's why I want to use this method on my items as well but I can't figure out how to convert it. I know that I should do it myself but been trying it for ages and can't make it, so what I'm asking is please I'm sure it's not hard for an advanced coder could you please convert it for me aka rewrite it? It's not really long in lines too, my guess would take ya like 10-15mins. I'd really appreciate it, thank you a lot!!!
p.s. I don't mind about the layout at ALL just need the page to show that image anywhere, thanks.
Estate.php ( house/property buying/viewing page ) the one that needs to be converted
Code: Select all
<?php
include_once('globals.php');
echo '<h2><font color=darkred>Estate Agent</font color></h2><font color=white>';
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 '<strong><font color=yellow>Your current Property:</font color></strong> <font color=white>', $house["hNAME"] ,' </font color>
<br />
<i><font color=white>Welcome to the estate agent, <font color=red>', $ir["username"] ,'</font color>. Here you can view the properties avaliable and purchase them.</font color></i>
<br /><br />';
$get = $db->query("SELECT `hNAME`,`hID` FROM `houses` ORDER BY `hWILL`,`hNAME` ASC");
while($r = $db->fetch_row($get))
{
echo "<font color=red><i>". $r['hNAME'] ."</i> » <a href='?p=viewHouse&id=".$r['hID']."'>View the house</a><br />";
}
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 property at the moment!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
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 property at the moment!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
exit( $h->endpage() );
}
$r = $db->fetch_row($exist);
echo "<h4> » <strong>Viewing:</strong> {$r['hNAME']} </h4>
<br />
<div style='width: 500px; padding: 5px; background: #D4D4D4; border: 1px solid #000000; text-align: center;'>
<img src='housepic/{$r['hNAME']}.png' height='200px' width='300px' style='border: 1px solid #D0D0D0;'>
</div>
<br />";
$color = ($ir['money'] >= $r['hPRICE']) ? "green" : "red";
echo "<font size='34pt' color='".$color."'>$".number_format($r['hPRICE'])."</font>
<br />
<br />
<strong>House Statistics</strong>
<br />
Amount owned: ". $q = $db->num_rows( $db->query("SELECT `userid` FROM `users` WHERE `maxwill`={$r['hWILL']}") ) ."
<br />
Will Increase: ". $will = ($r['hWILL'] / 100) * $ir['maxwill'] ."%";
if($color == "green" AND $ir['maxwill'] < $r['hWILL'])
{
echo "<br /><br /><font size='34pt'>» <a href='?p=buy&id=".$_GET['id']."'>Purchase</a>";
}
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 property at the moment!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
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 property at the moment!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
exit( $h->endpage() );
}
$r = $db->fetch_row($exist);
if($ir['money'] < $r['hPRICE'])
{
echo "You don't have enough money at the moment!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
exit( $h->endpage() );
}
if($ir['maxwill'] > $r['hWILL'])
{
echo "You don't want to get a smaller property do you?!
<br />
» <a href='?p=index'>Back to Estate Agent</a>";
exit( $h->endpage() );
}
echo "Congratulations, you have just purchased a {$r['hNAME']} for $".number_format($r['hPRICE'])."!
<br /><br>
» <a href='index.php'>Back Home</a>";
$db->query("UPDATE `users` SET `money`=`money`-{$r['hPRICE']},`maxwill`={$r['hWILL']} WHERE `userid`=$userid");
exit($h->endpage());
}
?>
iteminfo.php
Code: Select all
<?php
include "globals.php";
//look up item
$_GET['ID'] = abs((int) $_GET['ID']);
$itmid=$_GET['ID'];
if(!$itmid)
{
print "Invalid item ID";
}
else
{
$q=$db->query("SELECT i.*,it.* FROM items i LEFT JOIN itemtypes it ON i.itmtype=itmtypeid WHERE i.itmid=$itmid LIMIT 1");
if (!$db->num_rows($q))
{
print "Invalid item ID";
}
else
{
$id=$db->fetch_row($q);
///Item Image SQL
print "<b><h2>Information on the <u><font color=red>{$id['itmname']}</font color></u></b></h2><br>";
///Item Image:
///echo "<img src='itempics/{$r['itmname']}' height='160px' width='100px' style='border: 1px solid #000000;'>
echo "<br>The <b>{$id['itmname']}</b> is a/an {$id['itmtypename']} Item - <b>{$id['itmdesc']}</b>Item Info Item Buy Price Item Sell Price ";
if($id['itmbuyprice'])
{
print money_formatter($id['itmbuyprice']);
}
else
{
print "N/A";
}
print "";
if($id['itmsellprice'])
{
print money_formatter($id['itmsellprice']);
}
else
{
print "N/A";
}
}
}
$h->endpage();
?>
database name: legendaryassassins
table name: items
"items" structure