Re: Change styling depending on var value
| From: | Dan McCullough | Date: | Fri, 20 Nov 2009 20:32:51 +0000 |
| Subject: | Re: Change styling depending on var value | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299984@lists.php.net to get a copy of this message | ||
To add to what Ashley said about $row[3], remember that when you are
returning from the db the counter for fields will start at 0 not 1, so if
its the 3rd field that will be $row[2]. You might also want to do switch
rather then elseif but thats always a good debate.
On Fri, Nov 20, 2009 at 3:16 PM, Ashley Sheridan
<ash@ashleysheridan.co.uk>wrote:
> On Fri, 2009-11-20 at 15:11 -0500, Phil Matt wrote:
>
> > Ashley Sheridan wrote:
> >
> > > Well, you're main problem here is that you are only using a single =
> > > character. What that is saying to PHP is: "if you let me assign the
> > > value of $beverage to $row[3] then do this next bit", but what I think
> > > you wanted it to say was "if $row[3] is the same as $beverage then do
> > > this next bit", which would need == instead of =
> > >
> >
> > Thanks, Ashley. I don't do enough PHP to get used to the syntax.
> >
> > I changed the operators to ==, but my conditional apparently isn't
> > working correctly. I checked to make sure the values in the cells were
> > the strings as I've specified them, but the resultant formatting always
> > defaults to the ELSE color.
> >
> > Must be something very simple, but I'm just not getting it.
> >
> > Cheers --- Phil
>
>
> Don't forget to reply to all!
>
> Just a quick question, what do you get if you do:
>
> print $row[3];
>
> Does it contain a string like you expect?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>