Jump to content
MakeWebGames

Shops with item images, please help.


josh-j-c

Recommended Posts

right, ive added item images into my game and i wanted to create a simular style to which torn city has, ive set the database feilds ect and everythings working fine in my iteminfo.php file im just now stuck on the shop :(

Heres the code,

 

<?php
include "globals.php";
$_GET['shop'] = abs((int) $_GET['shop']);
if(!$_GET['shop'])
{
print "You begin looking through town and you see a few shops.<br />";
$q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}");
print "<table width=85% cellspacing=1 class='table'><tr style='background: gray;'><th>Shop</th><th>Description</th></tr>";
while($r=$db->fetch_row($q))
{
print "<tr><td><a href='shops.php?shop={$r['shopID']}'>{$r['shopNAME']}</a></td><td>{$r['shopDESCRIPTION']}</td></tr>";
}
print "</table>";
}
else
{
$sd=$db->query("SELECT * FROM shops WHERE shopID={$_GET['shop']}");
if($db->num_rows($sd))
{
$shopdata=$db->fetch_row($sd);
if($shopdata['shopLOCATION'] == $ir['location'])
{
print "Browsing items at <b>{$shopdata['shopNAME']}...</b><br />
<table cellspacing=1 class='table'><tr style='background: gray;'><th>Image</th><th>Weapon</th><th>Price</th><th>Sell Price</th><th>Buy</th></tr>";
$qtwo=$db->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");
$lt="";
while($r=$db->fetch_row($qtwo))
{
if($lt!=$r['itmtypename'])
{
$lt=$r['itmtypename'];
print "\n<tr style='background: gray;'><th colspan=5>{$lt}</th></tr>";
}
print "\n<tr><td>{$id['itempic']}</td><td>{$r['itmname']}</td><td>\${$r['itmbuyprice']}</td><td>\${$r['itmsellprice']}</td><td><form action='itembuy.php?ID={$r['itmid']}' method='post'>Qty: <input type='text' name='qty' value='1' /><input type='submit' value='Buy' /></form></td></tr>";
}
print "</table>";
}
else
{
print "You are trying to access a shop in another city!";
}
}
else
{
print "You are trying to access an invalid shop!";
}
}
$h->endpage();
?>

 

if anyone could shed some light and help me then that would be awesome, thank you.

Jc.

Link to comment
Share on other sites

<?php
include "globals.php";
$_GET['shop'] = abs((int) $_GET['shop']);
if(!$_GET['shop'])
{
print "You begin looking through town and you see a few shops.";
$q=$db->query("SELECT * FROM shops WHERE shopLOCATION={$ir['location']}");
print "<table width=85% cellspacing=1 class='table'><tr style='background: gray;'><th>Shop</th><th>Description</th></tr>";
while($r=$db->fetch_row($q))
{
print "<tr><td><a href='shops.php?shop={$r['shopID']}'>{$r['shopNAME']}</a></td><td>{$r['shopDESCRIPTION']}</td></tr>";
}
print "</table>";
}
else
{
$sd=$db->query("SELECT * FROM shops WHERE shopID={$_GET['shop']}");
if($db->num_rows($sd))
{
$shopdata=$db->fetch_row($sd);
if($shopdata['shopLOCATION'] == $ir['location'])
{
print "Browsing items at <b>{$shopdata['shopNAME']}...</b>
<table cellspacing=1 class='table'><tr style='background: gray;'><th>Image</th><th>Weapon</th><th>Price</th><th>Sell Price</th><th>Buy</th></tr>";
$qtwo=$db->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");
$lt="";
while($r=$db->fetch_row($qtwo))
{
if($lt!=$r['itmtypename'])
{
$lt=$r['itmtypename'];
print "\n<tr style='background: gray;'><th colspan=5>{$lt}</th></tr>";
}
print "\n<tr><td>{$r['itempic']}</td><td>{$r['itmname']}</td><td>\${$r['itmbuyprice']}</td><td>\${$r['itmsellprice']}</td><td><form action='itembuy.php?ID={$r['itmid']}' method='post'>Qty: <input type='text' name='qty' value='1' /><input type='submit' value='Buy' /></form></td></tr>";
}
print "</table>";
}
else
{
print "You are trying to access a shop in another city!";
}
}
else
{
print "You are trying to access an invalid shop!";
}
}
$h->endpage();
?>

 

Try This

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...