View Single Post

  #6 (permalink)  
Old 05-09-2008
Rik Wasmus
 
Posts: n/a
Default Re: show image when a field value = 1

tommybiegs@gmail.com wrote:
> On May 9, 10:28 am, "canaj...@gmail.com" <canaj...@gmail.com> wrote:
>> I am trying to get a script to show a particular image when a field
>> value = 1, otherwise it will show something else, and this is what I
>> came up with:
>>
>> $i=0;
>> while ($i < $num) {
>>
>> $name=mysql_result($result,$i,"name");
>> $date=mysql_result($result,$i,"date");
>> $status=mysql_result($result,$i,"status");
>>
>> echo "<b>$name</b>
>> <br><b>$date</b><br> ";
>>
>> if (status == 1) {
>> echo <img src='../images/yes.jpg'>
>> } else {
>> echo <img src='../images/no.jpg'>
>> }
>>
>> ;
>>
>> $i++;
>>
>> }
>>
>> and nothing shows up, if I remove the if clause then I get the text
>> showing name and date. What am I doing wrong, aside from not really
>> knowing how to program php?
>>
>> Thanks

>
> if ( status == 1 )
>
> is not the same as
>
> if ( $status == 1 )


Indeed. At the OP: set error_reporting(E_ALL | E_STRICT) while
developing, and enable display_errors. It would probably have told you
there is no constant 'status' defined.

--
Rik Wasmus
[SPAM]
Now looking for some smaller projects to work on to fund a bigger one
with delayed pay. If interested, mail rik at rwasmus.nl
[/SPAM]
Reply With Quote