> -----Original Message----- > From: Jason [mailto:[EMAIL PROTECTED]] > Sent: 16 September 2002 20:44 > > > I'm using PHP, MySql, DreamweaverMX, and PHAkt 2. I want to > add a comma ( > , ) to the end of a variable, but only if it exists in the database. > (Meaning I don't want a comma with no variable.) I seem to > remember a format > that didn't use an if/else statement that looked something like: > <?php echo xxx( $variable, \,) ?>
This may not be what you were thinking of exactly, but my usual approach to this is to use the ?: ternary operator thusly: echo isset($variable)?"$variable,":''; or, to omit empty strings and zero values also: echo empty($variable)?'':"$variable,"; Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php