orsino Posted November 1, 2020 Share Posted November 1, 2020 hi i was adding images to the items today now i need help on the last part the images are already working on pages like iteminfo or inventory the only part i cant seem to work is the equipped items on the website its showing img/nameoftheimg.png but i needs to show the img if (isset($equip[$ir['equip_primary']])) { print $equip[$ir['equip_primary']]['itmpic'] <------ this is where the img needs to be . "</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } <?php require_once('globals.php'); $q = $db->query( "SELECT `itmid`, `itmname`, `itmpic` FROM `items` WHERE `itmid` IN({$ir['equip_primary']}, {$ir['equip_secondary']}, {$ir['equip_armor']})"); echo "<h3>Equipped Items</h3><hr />"; $itmpic = ($i['itmpic']) ? "<img src='{$i['itmpic']}' class='thumbnail' style='background-color: transparent;' width='50px' height='50px'>" : ''; $equip = array(); while ($r = $db->fetch_row($q)) { $equip[$r['itmid']] = $r; } $db->free_result($q); echo "<table width='75%' cellspacing='1' class='table'> <tr> <th>Primary Weapon</th> <td>"; if (isset($equip[$ir['equip_primary']])) { print $equip[$ir['equip_primary']]['itmpic'] . "</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Secondary Weapon</th> <td>"; if (isset($equip[$ir['equip_secondary']])) { print $equip[$ir['equip_secondary']]['itmpic'] . "</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Armor</th> <td>"; if (isset($equip[$ir['equip_armor']])) { print $equip[$ir['equip_armor']]['itmpic'] . "</td><td><a href='unequip.php?type=equip_armor'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } $itmpic = ($i['itmpic']) ? "<img src='{$i['itmpic']}' class='thumbnail' style='background-color: transparent;' width='50px' height='50px'>" : ''; echo "</tr> </table><hr /> <h3>Inventory</h3><hr />"; $inv = $db->query( "SELECT `inv_qty`, `itmsellprice`, `itmid`, `inv_id`, `effect1_on`, `effect2_on`, `effect3_on`, `itmname`, `itmpic`, `weapon`, `armor`, `itmtypename` FROM `inventory` AS `iv` INNER JOIN `items` AS `i` ON `iv`.`inv_itemid` = `i`.`itmid` INNER JOIN `itemtypes` AS `it` ON `i`.`itmtype` = `it`.`itmtypeid` WHERE `iv`.`inv_userid` = {$userid} ORDER BY `i`.`itmtype` ASC, `i`.`itmname` ASC"); if ($db->num_rows($inv) == 0) { echo "<b>You have no items!</b>"; } else { echo "<b>Your items are listed below.</b><br /> <table width=100% class=\"table\" border=\"0\" cellspacing=\"1\"> <tr> <td class=\"h\">Item</td> <td class=\"h\">Img</td> <td class=\"h\">Sell Value</td> <td class=\"h\">Total Sell Value</td> <td class=\"h\">Links</td> </tr>"; $lt = ""; while ($i = $db->fetch_row($inv)) { if ($lt != $i['itmtypename']) { $lt = $i['itmtypename']; echo "\n<tr> <td colspan='4'> <b>{$lt}</b> </td> </tr>"; } if ($i['weapon']) { $i['itmname'] = "<span style='color: red;'>*</span>" . $i['itmname']; } if ($i['armor']) { $i['itmname'] = "<span style='color: green;'>*</span>" . $i['itmname']; } echo "<tr> <td>{$i['itmname']}"; if ($i['inv_qty'] > 1) { echo " x{$i['inv_qty']}"; } $itmpic = ($i['itmpic']) ? "<img src='{$i['itmpic']}' class='thumbnail' style='background-color: transparent;' width='50px' height='50px'>" : ''; echo "</td> <td> {$itmpic} </td> <td>" . money_formatter($i['itmsellprice']) . "</td> <td>"; echo money_formatter($i['itmsellprice'] * $i['inv_qty']); echo "</td> <td> [<a href='iteminfo.php?ID={$i['itmid']}'>Info</a>] [<a href='itemsend.php?ID={$i['inv_id']}'>Send</a>] [<a href='itemsell.php?ID={$i['inv_id']}'>Sell</a>] [<a href='imadd.php?ID={$i['inv_id']}'>Add To Market</a>]"; if ($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { echo " [<a href='itemuse.php?ID={$i['inv_id']}'>Use</a>]"; } if ($i['weapon'] > 0) { echo " [<a href='equip_weapon.php?ID={$i['inv_id']}'>Equip as Weapon</a>]"; } if ($i['armor'] > 0) { echo " [<a href='equip_armor.php?ID={$i['inv_id']}'>Equip as Armor</a>]"; } echo "</td> </tr>"; } echo "</table>"; $db->free_result($inv); echo "<small><b>NB:</b> Items with a small red </small><span style='color: red;'>*</span><small> next to their name can be used as weapons in combat.<br /> Items with a small green </small><span style='color: green;'>*</span><small> next to their name can be used as armor in combat.</small>"; } $h->endpage(); 1 Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 1, 2020 Share Posted November 1, 2020 5 hours ago, orsino said: but i needs to show the img Standard HTML for ya here - wrap it in an img tag. Replace print $equip[$ir['equip_primary']]['itmpic']. " with echo "<img src='".$equip[$ir['equip_primary']]['itmpic']."' alt=''> 1 Quote Link to comment Share on other sites More sharing options...
orsino Posted November 2, 2020 Author Share Posted November 2, 2020 thank you 1 Quote Link to comment Share on other sites More sharing options...
Oracle Posted May 5 Share Posted May 5 (edited) May someone please post the SQL for this script? and the beginning of the script? please and thank you 😃 Edited May 5 by Oracle needed to add more info Quote Link to comment Share on other sites More sharing options...
peterisgb Posted May 5 Share Posted May 5 10 hours ago, Oracle said: May someone please post the SQL for this script? and the beginning of the script? please and thank you 😃 you need to add the field "itmpic" you items where your game items are stored and i think thats it Quote Link to comment Share on other sites More sharing options...
Oracle Posted May 20 Share Posted May 20 On 5/5/2023 at 3:50 PM, peterisgb said: you need to add the field "itmpic" you items where your game items are stored and i think thats it Thank you going to try that 😃 On 5/5/2023 at 3:50 PM, peterisgb said: you need to add the field "itmpic" you items where your game items are stored and i think thats it I tried INSERT INTO `items`(`itempic`) INSERT INTO `items`(`itmpic`) and it's still not accepting it Quote Link to comment Share on other sites More sharing options...
corruptcity || skalman Posted May 20 Share Posted May 20 Hi, use this but change `images` to itempic, itmpic etc ALTER TABLE `items` ADD `image` TEXT NOT NULL AFTER `itmpic`; that will add the field to the table so that you can then to hold the image link Quote Link to comment Share on other sites More sharing options...
Oracle Posted May 20 Share Posted May 20 59 minutes ago, corruptcity || skalman said: Hi, use this but change `images` to itempic, itmpic etc ALTER TABLE `items` ADD `image` TEXT NOT NULL AFTER `itmpic`; that will add the field to the table so that you can then to hold the image link Inserted that string and came back with an error do you know what the exact thing to post into SQL ? Quote Link to comment Share on other sites More sharing options...
corruptcity || skalman Posted May 20 Share Posted May 20 forgot to say you need to set After `itmpic` to what ever the last field name is in your table Quote Link to comment Share on other sites More sharing options...
Oracle Posted May 24 Share Posted May 24 On 5/20/2023 at 4:14 PM, corruptcity || skalman said: forgot to say you need to set After `itmpic` to what ever the last field name is in your table What will help? what should I put at the end? I want it to be img Quote Link to comment Share on other sites More sharing options...
newttster Posted May 24 Share Posted May 24 11 hours ago, Oracle said: What will help? what should I put at the end? I want it to be img Go to your database, open the "items" table, click on the "structure" tab, under the table you will see where you can "Add column(s)". Enter 1, choose where in the table you want to place the new column and click on the "Go". When that opens up, type the name (I would use "itemimg", if you really NEED to have the phrase img) of your column under "Name", in the drop down in the next field choose text, then click save. And voila ... "img" field is now added to your items table. Quote Link to comment Share on other sites More sharing options...
Oracle Posted May 27 Share Posted May 27 On 5/24/2023 at 6:51 AM, newttster said: Go to your database, open the "items" table, click on the "structure" tab, under the table you will see where you can "Add column(s)". Enter 1, choose where in the table you want to place the new column and click on the "Go". When that opens up, type the name (I would use "itemimg", if you really NEED to have the phrase img) of your column under "Name", in the drop down in the next field choose text, then click save. And voila ... "img" field is now added to your items table. that sounds great ! do I need a php page to help bring up the iem in staff.php? what I mean is what is the code that I need to use for itmpic / image on DemonsAndAngels (makeweb.games) / Staff etc Quote Link to comment Share on other sites More sharing options...
newttster Posted May 29 Share Posted May 29 The staff.php page as written, as I recall, does not allow you to put images into your items db. If I'm using images, I do it directly through the db. There is no specific code that I use for that. When accessing my db I don't use any specific "code" I just use names, etc. that make sense for that particular table/item, etc.. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted Tuesday at 02:21 PM Share Posted Tuesday at 02:21 PM The ability to set image paths via the staff_items.php's add/edit item methods could be added. This would allow you (and your staff) to set `path/to/someImage.png` (example) when creating/editing an item directly within the staff panel, as opposed to needing to log into the database - to which, I presume, isn't something you'd normally grant your game staff access. So yeah, modify add/edit item, set image path! Quote Link to comment Share on other sites More sharing options...
newttster Posted Tuesday at 08:39 PM Share Posted Tuesday at 08:39 PM I agree 100% with that, MTG. And have done so in the past. I just didn't want to confuse Oracle any further on how to do that as she seems a little confused on how to just insert the field and images into the db. Quote Link to comment Share on other sites More sharing options...
Uridium Posted Tuesday at 10:27 PM Share Posted Tuesday at 10:27 PM I wrote a script for this that allowed IMAGE PATHS to be inserted when a new Item was being created Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.