SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Apr 4, 2005, 23:24 #1
- Join Date
- Jan 2004
- Location
- Seattle
- Posts
- 4,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Adding plural s when fetching data from db (was:Ssssssssssssssssssssss)
In the script below, 'Name' summons the name of a state, while 'DesigGeneral' summons the name of a state symbol. Thus, it might display "Arizona's State Mammal."
PHP Code:<?php
if($r['Symbol'] !=''):
$ChildName = $r['Name'] . "’s State " . strtotitle($r['DesigGeneral']);
endif; ?>
DesigGeneral | Symbol
Mammal | white-tailed deer
Mammal | raccoon
Mammal | Morgan horse
How can I modify my script so that it adds an S if there are more than one entries for 'DesigGeneral'? In other words, I'd like it to display...
Arizona's State Mammal
Texas' State Mammals
Thanks.
-
Apr 4, 2005, 23:36 #2
- Join Date
- Mar 2005
- Posts
- 40
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi there,
try something like that.
if (mysql_num_rows($whatever) > 1) $ChildName .= 's';
-
Apr 5, 2005, 01:31 #3
- Join Date
- Jan 2004
- Location
- Seattle
- Posts
- 4,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by GStyle
PHP Code:<?php
// TITLE & NAVHERE
if($r['Symbol'] !=''):
$ChildName = $r['Name'] . "’s State " . strtotitle($r['DesigGeneral']);
else:
$ChildName = $data_details['Name'] . "’s State " . $mytopic . ", etc.";
endif;
if (mysql_num_rows($r['DesigGeneral']) > 1) $ChildName .= 's';
?>
-
Apr 5, 2005, 02:19 #4
- Join Date
- Mar 2005
- Location
- The Netherlands
- Posts
- 73
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mysql_num_rows wants a as parameter the result of a mysql_query.
You are giving him just an array...There is no signature...
Bookmarks