startheaders();
include "mysql.php";
global $c;
$is =
mysql_query(
"SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",
$c) or die(mysql_error());
$ir = mysql_fetch_array($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->menuarea();
$_GET['shop'] = abs((int) $_GET['shop']);
if (!$_GET['shop'])
{
print "You begin looking through town and you see a few shops.
";
$q =
mysql_query(
"SELECT * FROM shops WHERE shopLOCATION={$ir['location']}",
$c);
print
"
| Shop | Description |
";
while ($r = mysql_fetch_array($q))
{
print
"| {$r['shopNAME']} | {$r['shopDESCRIPTION']} |
";
}
print "
";
}
else
{
$sd = mysql_query("SELECT * FROM shops WHERE shopID={$_GET['shop']}", $c);
if (mysql_num_rows($sd))
{
$shopdata = mysql_fetch_array($sd);
if ($shopdata['shopLOCATION'] == $ir['location'])
{
print
"Browsing items at {$shopdata['shopNAME']}...
| Item | Description | Price | Sell Price | Buy |
";
$qtwo =
mysql_query(
"SELECT si.*,i.*,it.* FROM shopitems si LEFT JOIN items i ON si.sitemITEMID=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE si.sitemSHOP={$_GET['shop']} ORDER BY i.itmtype ASC, i.itmbuyprice ASC, i.itmname ASC",
$c) or die(mysql_error());
$lt = "";
while ($r = mysql_fetch_array($qtwo))
{
if ($lt != $r['itmtypename'])
{
$lt = $r['itmtypename'];
print
"\n| {$lt} |
";
}
print
"\n| {$r['itmname']} | {$r['itmdesc']} | \${$r['itmbuyprice']} | \${$r['itmsellprice']} | |
";
}
print "
";
}
else
{
print "You are trying to access a shop in another city!";
}
}
else
{
print "You are trying to access an invalid shop!";
}
}
$h->endpage();