Shopping Cart Forum

Go Back   eShop Forums - eCommerce Help Forum for Shopping Cart Owners. > Tech Corner > PHP/MySQL ASP.net and other server side technologies
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
PHP/MySQL ASP.net and other server side technologies Everything to do with the programming of websites. Discuss what goes on under the bonnet of your ecart or just chat about programming in general.

Sell your Products via hundreds of web sites, Click Here!
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-10-2007, 04:01 AM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,100
Thanks: 0
Thanked 65 Times in 65 Posts
Default How to Print Correct Plurals.

One thing that niggles me on some sites is the incorrect use of plurals. I'm sure you've all seen examples of this, such as "You have 1 items in your basket" or "1 guests online". It's just pure laziness on behalf of the programmer and can easily be rectified with a single line of code.

This is how it's done


PHP Code:
echo "You have $number " . ($number == 'Item' 'Items') . " in your basket."
Where $number is the number of items in the user's basket. That's all there is to it.

There are some slightly more complicated versions than that, such as "There is 1 guest online" and "There are 17 guests online", but I'm sure you can work out how to do this by using the same principle I used above.
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Google

Edible Graphics, Affordable E-Commerce, Web Shops & Custom Form Scripts
Fair Trade Quality Handmade Photo Albums & Gifts
tech news, product reviews, the latest home and business technology, the latest in digital imaging


Content Relevant URLs by vBSEO 3.0.0