Jump to content
MakeWebGames

Help with adding images to shop.php


lynm77
 Share

Recommended Posts

Hello All

I hope someone may be able to help me with the following problem im having trying to add images to shops.php

Even after uploading images and changes to script when i click on image the detaila i get our as follows

http://www.xxxxxxx.com/itmpics/%7B$i[

This is my script for shop.php

Hope fully someone can guide me to what im doing incorrect

Thanks

 

<?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>Item</th><th>Description</th><th>Price</th><th>Sell Price</th><th>Buy</th><th>Credit Card</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=8>{$lt}</th></tr>";
}
$buyprice=money_formatter($r['itmbuyprice']);
$sellprice=money_formatter($r['itmsellprice']);
$creditcardbuyprice=money_formatter($r['itmbuyprice']);
?><tr><td><img src='itmpics/{$i['itmpic']}' height='70px' width='70px'></td><td><? echo $r['itmname']; ?></td><td><? echo $r['itmdesc']; ?></td><td><? echo $buyprice; ?></td><td><? echo $sellprice; ?></td><td><form action='itembuy.php?ID=<? echo $r['itmid']; ?>' name="shopbuy" method='post'>
Qty: <input type='text' name='qty' value='1'  onkeyup="tot(<? echo $r['itmid']; ?>,<? echo $r['itmbuyprice']; ?>,this.value);" onfocus="clearText(this);" onblur="returnText(this);" /><input type='submit' value='Buy' /></form><div id="res<? echo $r['itmid']; ?>" align="left"></div></td><td>

<form action='creditcarditembuy.php?ID=<? echo $r['itmid']; ?>' name="shopbuy" method='post'>
Qty: <input type='text' name='qty' value='1'  onkeyup="tot(<? echo $r['itmid']; ?>,<? echo $r['itmbuyprice']; ?>,this.value);" onfocus="clearText(this);" onblur="returnText(this);" /><input type='submit' value='Buy' /></form><div id="res<? echo $r['itmid']; ?>" align="left"></div></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();
?>
Edited by lynm77
incorrect
Link to comment
Share on other sites

<img src='itmpics/{$i['itmpic']}'

Should be

<img src='itmpics/'.$i['itmpic'].''

Actually curly brackets do the same, just with less work :)

So now try changing this:

{$i['itmpic']}

To this:

{$r['itmpic']}

 

Let me know how that goes for you.

Edited by Arson
Link to comment
Share on other sites

Hello

I have tried the following changes now all have not worked sadly

with this <img src='itmpics/{$i['itmpic']}'

i get the following when i click on image the details i get are as follows

http://www.xxxxxxx.com/itmpics/%7B$i[

With this <img src=itmpics/'.$i['itmpic].''

i get the following when i click on image the details i get are as follows

http://www.xxxxxx.com/itmpics/

With this <img src='itmpics/{$r['itmpic']}'

i get the following when i click on image the details i get are as follows

http://www.xxxxxxx.com/itmpics/%7B$r[

So none are selecting the images for the item from the itmpics folder

Thanks to all that has helped todate but still not working any other ideas would be appreciated

Link to comment
Share on other sites

Oh wow, don't know why I didn't notice this before. :o

Change {$i['itmpic']}

with <?php echo $r['itmpic']; ?>

Actually curly brackets do the same, just with less work smile.png

-snip-

Yes, but this is what happens when I don't actually bother reading the script, before answering.

I just noticed ' ... ', in which I just assumed, "echo ' ... ';" (again not reading), therefore { } don't work. ;)

Edited by Djkanna
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.

 Share

×
×
  • Create New...