Re: is_null question
| From: | Jason White | Date: | Sat, 13 Jul 2002 04:36:34 +0000 |
| Subject: | Re: is_null question | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-107474@lists.php.net to get a copy of this message | ||
My appologies, I didn't read clear through, your code block confused me :-)
What I usually do in a situation like this, although I'm new to PHP is.
$temp="Some stuff before Email";
if($row[1]){
$temp .= "Email:$row[1]";
}
$temp .= "The rest of the stuff after Email";
print $temp;
Jason White
----- Original Message -----
From: "Jason White" <jasona@inetarena.com>
To: "Matthew K. Gold" <mgold1@gc.cuny.edu>; <php-general@lists.php.net>
Sent: Friday, July 12, 2002 9:28 PM
Subject: Re: [PHP] is_null question
> You can use:
>
> if($row[1]){print "Email:$row[1]";}else{print " ";}
>
> Jason White
>
> ----- Original Message -----
> From: "Matthew K. Gold" <mgold1@gc.cuny.edu>
> To: <php-general@lists.php.net>
> Sent: Friday, July 12, 2002 9:23 PM
> Subject: [PHP] is_null question
>
>
> > Hi Everyone,
> >
> > Here's my problem: I'd like to make the printing of some text dependent
> on
> > whether or not a variable is null. In the following example, when
$row[1]
> > is null, what gets printed on the page is "Email: ". I'd like the
> > script to not print "Email:" if row[1] is null.
> >
> > It looks like I should be using is_null(), but I'm not sure how to use
it,
> > especially since all of this is embedded in a print statement.
> >
> > while ($row = mysql_fetch_row ($result))
> > {
> > print ("\t<tr
> > bgcolor=\"#ff9900\">\n\t\t<th>$row[0]</th>\n</tr>\n\t<tr
> > class=\"default\"
> > bgcolor=\"#ffffff\">\n\t\t<td><p>$row[10]</p><p>Email:
> <a
> >
> > href=\"mailto:$row[1]\">$row[1]</a><br
> > />Phone:
$row[2]</p>\n\n<p>Address:
> > $row[3]<br />$row[4]<br />$row[5] $row[6] $row[7]</p> <p>URL:
> > <a
> > href=\"$row[8]\"
> > target=\"_blank\">$row[8]</a></p></td></tr>");
> > }
> >
> >
> > Instead of just printing Email: $row[1], I'd like to test whether it's
> null
> > first--maybe something like this?
> >
> > if (is_null($row[1])) print " " else print ("Email: $row[0]")
> >
> > but can I put that line inside of another print statement? if so, do I
> have
> > to escape the quotation marks? Please forgive my confusion--I'm new to
> > programming in general and PHP in particular.
> >
> > Thanks in advance for your help.
> >
> > best,
> >
> > Matt
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>