/    Sign up×
Community /Pin to ProfileBookmark

Recordset Show If Empty

Hi

I am working on a site where some of the Recordsets are empty here is the coding I am working with

[code=php]
<td><?php if ($totalRows_Recordset1 == 0) { // Show if recordset empty ?>
<div id=”masterwrapper”>
<div id=”masterheader”><a href=”products.php?recordID=<?php echo $row_Recordset1[‘product_name’]; ?>”><?php echo $row_Recordset1[‘product_name’]; ?>&nbsp;</a></div>
<div id=”masterpicture”><?php echo $row_Recordset1[‘main_image’]; ?></div>
<div id=”masterdetails”><?php echo $row_Recordset1[‘packing_slip_desc’]; ?></div>
<div id=”masterbuynow”>
<form id=”form1″ name=”form1″ method=”post” action=”cart.php”>
$
<?php echo $row_Recordset1[‘price’]; ?>
</form>
</div>
</div>
<?php } // Show if recordset empty ?></td>
[/code]

What I want is for nothing to show in the Master Wrapper if there is no record. Then I want it to say we apologize for an inconvenience this may have caused you but we do not have any of those products in stock. Please check back soon.

Any Help Is much appriciated

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@iosysMay 28.2011 — It looks like you have the script setup right?

It deletes it if field returns "0" so just add this?

echo "<p>We apologize for an inconvenience this may have caused you but we do not have any of those products in stock.</p><p> Please check back soon.</p>";
Copy linkTweet thisAlerts:
@shutterbugauthorJun 07.2011 — Where do i add the echo on this code

[code=php]
<?php if ($totalRows_Recordset1 > 0) { // Show if recordset not empty ?>
<div id="masterwrapper">
<div id="masterheader"><a href="Master_Results.php?recordID=<?php echo $row_Recordset1['product_name']; ?>"> <?php echo $row_Recordset1['product_name']; ?>&nbsp; </a></div>
<div id="masterpicture"><?php echo $row_Recordset1['main_image']; ?></div>
<div id="masterdetails"><?php echo $row_Recordset1['packing_slip_desc']; ?></div>
<div id="masterbuynow">$<?php echo $row_Recordset1['price']; ?><br /><form id="form1" name="form1" method="post" action="cart.php">
<p>
<input type="hidden" name="product_name" id="product_name" value="<?php echo $row_Recordset1['product_name']; ?>" />
<input type="submit" name="button" id="button" value="Add to Shopping Cart" />&nbsp;</p>
</form>
</div>
</div>
<?php }// Show if recordset not empty ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

No Items THanks
</div>
<div id="footer">
<?php include_once'template_footer.php' ?>

[/code]
×

Success!

Help @shutterbug spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...