Not sure if this has been done before,so yeah, sorry in advance if it has. But, after looking through most of the mods section, and searching for anything like it I found nothing..
Anyhoo, quick small mod to add images to houses. No SQL, yey!
One page and a small addon for index.php and smenu.php
First off copy and paste this and save it as house_app.php
<?php
include "sglobals.php";
global $db, $ir, $c, $h, $userid, $set;
if($ir['user_level'] != 2) {
echo 'Admins Only!';
exit;
}
echo '<h3>House Image</h3> <hr />
';
echo "<form method='get' action='house_app.php'>"
, house_dropdown($c, "house") ,
"<input type='submit' value='Submit' />
</form>
<hr />
";
$hid = $_GET['house'];
$query = mysql_query("SELECT `hNAME` FROM `houses` WHERE `hID` = '$hid'");
$row = mysql_fetch_array($query);
$hname = $row['hNAME'];
$hash = md5($row['hNAME']);
if (empty($hname)) {
echo 'Property does not exist!';
exit;
}
echo <<<EOF
<table width='75%' border='1'>
<tr>
<td>House ID:</td>
<td>$hid</td>
</tr>
<tr>
<td>House Name:</td>
<td>$hname</td>
</tr>
<tr>
<td>Image SRC:</td>
<td>$hash</td>
</tr>
</table>
EOF;
?>
Then add this under the first table in index.php, or any where you want I guess..
$hname = $ir['hNAME'];
$hid = $ir['hID'];
$src = md5($ir['hNAME']);
echo '
' , '<img src=\'houses/' , $src , '.jpg\' alt=\'' , $hname , '\' />';
Finally, the link for smenu.php
> [url='house_app.php']House Image[/url]
What it does:
All this app/mod does it generate a md5 hash of the house name in index.php, and then outputs it as part of the filename. Then, all you do is get whatever image you want for the house and lookup the house name and assoctiated hash in house_app.php and save the image as that. Not the prettiest of solutions, but works fine for me.
Small note, the default directory for the house images, is 'houses', so if you want to use a different directory you'll need to change this line in index.php:
echo '
' , '<img src=\'houses/' , $src , '.jpg\' alt=\'' , $hname , '\' />';
Changing the "houses" line..