Need help to modify php ELSE code


Posted on 16th Feb 2014 07:03 pm by admin

I'm trying to find a way to have the php code display a message if there is no inventory listed in the box, I just want it to say something like "User has no inventory listed"
You can see the actual box http://modern-wireless-inc.wassociation.com titled Inventory Wizard. Its on the right.
I want all the content in the box disappear if there is nothing in the inventory and only display the message. Is it hard to do?


Code: <?PHP if (!$item)
{
?>
<div class="account-left-column"><div><img src="images/account-left-column-back-top.gif" alt="" /></div>
<div class="account-left-column-header">Inventory Wizard Items</div>

<div class="account-left-column-content">
<form action="search.php" method="get" >
<p>Search <?PHP echo $vuser->co_name; ?> Inventory:</p>
<input type="text" name="q" size="30" maxlength="250" accesskey="S" />
<input name="Submit" type="submit" class="button" value="SEARCH" />

<input name="onlyinventory" type="hidden" value="yes" />
<input name="searchuserid" type="hidden" value="<?PHP echo $v_id; ?>" />
</form>
<table width="260" align="left" cellpadding="2" cellspacing="2">

<tr>
<td colspan="6" align="left" valign="top"> <p>Last 10 inventory items added:</p> </td>
</tr>

<tr>
<td colspan="3" align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"><strong>Category</strong></td>
<td align="left" valign="top"><strong>Model</strong></td>
<td align="left" valign="top"><strong>Description</strong></td>
</tr>

<?php

}

$inventories = $db->get_results("SELECT id,category,brand,model,description,qty,price,price_negotiable,picture_1,picture_2,inventory_timestamp FROM inventory where user_id in ($allempids) and status = 'active' order by id desc limit 10 ");

if ($inventories)
{
foreach ( $inventories as $invt )

{
$selected_category_phone = "";
$selected_category_accessory = "";
$selected_category_parts = "";

if ($invt->category == "phone"){$selected_category_phone = ' selected="selected" '; }
if ($invt->category == "accessory"){$selected_category_accessory = ' selected="selected" '; }
if ($invt->category == "parts"){$selected_category_parts = ' selected="selected" '; }

if (!$item)
{

$invt->description = substr($invt->description,0,25);
?>
<tr onmouseover="this.bgColor='#f1f0f0'" onmouseout="this.bgColor='#FFFFFF'">
<td align="left" valign="top">

<?PHP echo $invt->category; ?> </td>
<td align="left" valign="top">

<?PHP echo $invt->model; ?></td>
<td align="left" valign="top">
<a href="inventory.php?view_id=<?PHP echo $v_id; ?>&item=<?PHP echo $invt->id; ?>">
<?PHP echo $invt->description; ?>...</a></td>
</tr>

<?php
}
else
{
?>

<?php
}
}
}

?>
</table>

<div class="account-button"><a href="inventory.php?view_id=<?PHP echo $v_id; ?>">See All Inventory</a></div></div>
<!-- end of .account-left-column -->
<div><img src="images/account-left-column-back-bottom.gif" alt=""/></div></div>

No comments posted yet

Your Answer:

Login to answer
80 Like 32 Dislike
Previous forums Next forums
Other forums

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

Help =( !! Upload Pics [PHP script]
Hello
I need help with a php script [MULTIPLE UPLOAD IMAGES] , where I want to add a feature (wat

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

Final year project, please point me in the right direction
hi there for my final year project I'm aiming to build a php script shell to use as an expert system

Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if

Not capturing all the information we require in the form.......
Hi Guys,

I was wondering if you would share some more of your knowledge today, I'm hoping it

Apple's revamped lineup arrives

I'm personally curious about the magic mouse.. a multi-touch concept sounds like it could be nea

how to timeout $doc = new DOMDocument()->load($url)
I am currently using this $doc->load($url) to fetch an rss feed.
If a feed takes long than

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash