Jump to content
MakeWebGames

equipped img


orsino

Recommended Posts

 

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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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 "&nbsp;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();

 

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
  • 2 weeks later...
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 

Link to comment
Share on other sites

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 ? 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

 

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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!

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...