-
1. Re: How to display image if field value= 'value'
TwoSuits Oct 9, 2014 4:21 PM (in response to Max Resnikoff)If I understand you question correctly, you just need a PHP If statement inside the cell. Assuming you have a recordset from your database (if not just change the variable as necessary) it would look something like this:
<table>
<tr>
<td>Invoice Paid:</td>
<td>
<?php If ($yourRecodset['payment']==0) { ?>
<img src="notpaid.jpg"/>
<?php } else { ?>
<img src="paid.jpg"/>
<?php }?>
</td>
</tr>
</table>
(this assumes that the value can only be 0 or 1. If that is not the case, the Else should be replaced with another If)
Hope this helps
Scott
-
2. Re: How to display image if field value= 'value'
Max Resnikoff Oct 13, 2014 8:12 AM (in response to Max Resnikoff)Thanks,
This is what I have:
<?php echo $row_clientinfo['paymentstatus']; ?>
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php }}?>
But it doesnt seem to change if the value is 4.
Is there something im missing?
I have the field echoed on the page and it displays the right number, so it isnt something to do with the database.
-
3. Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 8:21 AM (in response to Max Resnikoff)You have nested your 'if ($clientinfo['paymentstatus']==4) {' statement inside your 'if ($clientinfo['paymentstatus']==0) {' statement. This means that the condition 4 code will never be seen as that block is only run when the value is 0.
It should read:
<?php echo $row_clientinfo['paymentstatus']; ?>
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php }?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php }?>
Notice the first if statement is closed before the second is reached.
Scott
-
4. Re: How to display image if field value= 'value'
MurraySummers Oct 13, 2014 8:27 AM (in response to Max Resnikoff)Is there something im missing?
Yes - you have improperly (or inadvertently) nested your conditional tests -
<?php echo $row_clientinfo['paymentstatus']; ?>
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php }?>
The way you had it written, the only time you would test to see if the value is 4 would be if the value==0 test SUCCEEDED.
-
5. Re: How to display image if field value= 'value'
Max Resnikoff Oct 13, 2014 8:32 AM (in response to TwoSuits) -
6. Re: How to display image if field value= 'value'
osgood_ Oct 13, 2014 8:48 AM (in response to Max Resnikoff)Max Resnikoff wrote:
It is still not working even with your code :/
The first set for the not paid code is working. If i change the 0 to 1, it dissapears.
The second set doesnt want to work even if i change the equal to:1
Try:
<?php echo $row_clientinfo['paymentstatus']; ?>
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
Should work if you database is set to 0 and 4 respectively/
-
7. Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 8:52 AM (in response to Max Resnikoff)As the code in your last post stands, the only way the paid image will display is if the value is set to 4. If you want it to work with 0 and 1, where 1 is paid, you need to change
<?php if ($clientinfo['paymentstatus']==4) { ?>
to
<?php if ($clientinfo['paymentstatus']==1) { ?>
-
8. Re: How to display image if field value= 'value'
MurraySummers Oct 13, 2014 8:49 AM (in response to osgood_)Os, I don't think we are getting through...
-
9. Re: How to display image if field value= 'value'
osgood_ Oct 13, 2014 8:56 AM (in response to MurraySummers)Infact you probably only need to test for NOT paid and just print paid if it doesnt meet the condition:
<?php echo $row_clientinfo['paymentstatus']; ?>
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php }
else { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
-
10. Re: How to display image if field value= 'value'
osgood_ Oct 13, 2014 8:59 AM (in response to MurraySummers)MurraySummers wrote:
Os, I don't think we are getting through...
I hear ya Murray, how you doing? Not seen you around in a while - been busy?
-
11. Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 9:10 AM (in response to osgood_)Can you guys (MurraySummers and osgood_) even see my replies? You seem to be repeating my answers. Your last is essentially the same as my original answer to the OP and the others are verbatim code to my second reply (apart from whitespace). If wires are crossing during posting then fine but you guys just seem to not even see/acknowledge my responses?
-
12. Re: How to display image if field value= 'value'
MurraySummers Oct 13, 2014 9:14 AM (in response to TwoSuits)Sorry I omitted you. Indeed your initial answer is correct.
-
13. Re: How to display image if field value= 'value'
MurraySummers Oct 13, 2014 9:15 AM (in response to osgood_)Yes - comes in waves, you know?
-
14. Re: How to display image if field value= 'value'
Max Resnikoff Oct 13, 2014 9:53 AM (in response to osgood_)I found the issue:
The variable was the problem.
Instead of this:
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
I put this:
<?php $paymentstatus = $row_clientinfo['paymentstatus']; ?>
<?php if ($paymentstatus ==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($paymentstatus ==1) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
-
15. Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 10:06 AM (in response to Max Resnikoff)The variable is not the issue. The top one contains:
<?php if ($clientinfo['paymentstatus']==4) { ?>
whereas the bottom one contains:
<?php if ($clientinfo['paymentstatus']==1) { ?>
The reason it doesn't work is because the top version is looking for a value of 4 which does not exist!
-
16. Re: Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 10:11 AM (in response to Max Resnikoff)Max Resnikoff wrote:
I found the issue:
The variable was the problem.
Instead of this:
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
I put this:
<?php $paymentstatus = $row_clientinfo['paymentstatus']; ?>
<?php if ($paymentstatus ==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($paymentstatus ==1) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
Do you see the problem?
-
17. Re: How to display image if field value= 'value'
osgood_ Oct 13, 2014 12:01 PM (in response to Max Resnikoff)Max Resnikoff wrote:
I found the issue:
The variable was the problem.
Instead of this:
<?php if ($clientinfo['paymentstatus']==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($clientinfo['paymentstatus']==4) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
I put this:
<?php $paymentstatus = $row_clientinfo['paymentstatus']; ?>
<?php if ($paymentstatus ==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($paymentstatus ==1) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
The reason it doesn't work is because the top version is looking for a value of 4 which does not exist!
Sorry TwoSuits - just winding you up - no offense meant - wasn't ignoring your replies, just thought maybe the OP wasn't understanding so just really reinforcing what you wrote.
-
18. Re: How to display image if field value= 'value'
osgood_ Oct 13, 2014 12:03 PM (in response to MurraySummers)MurraySummers wrote:
Yes - comes in waves, you know?
Yeah, same here. All or nothing.
-
19. Re: How to display image if field value= 'value'
Max Resnikoff Oct 13, 2014 1:51 PM (in response to TwoSuits)I changed it. I only put 4 just to test it to see if it would work with 4!
-
20. Re: Re: How to display image if field value= 'value'
TwoSuits Oct 13, 2014 2:19 PM (in response to Max Resnikoff)You do realise that the extra variable ($paymentstatus) is not required and that the below code will work exactly the same?
<?php if ($row_clientinfo['paymentstatus'] ==0) { ?>
<img src="../../images/notpaid.png" width="100" height="50" />
<?php } ?>
<?php if ($row_clientinfo['paymentstatus'] ==1) { ?>
<img src="../../images/paid.png" width="100" height="50" />
<?php } ?>
Oh, and by the way - YOU'RE WELCOME!
-
21. Re: Re: How to display image if field value= 'value'
Max Resnikoff Oct 13, 2014 2:23 PM (in response to TwoSuits)Well it didnt work with me. As soon as I changed it to a variable it worked.



