If Esle Clause

Hi, I am trying to create an if else clause that based on whether the database has information in a particular column a hyperlink will or will not be displayed.

I have currently done the following

<?php $pdf = $row_getProducts['part_pdf']; if ($pdf == "NULL" ) { echo "testing"; } else echo "" ?>

I have reversed the display so I can check it is working ie If NULL it will display testing! however when working I would swap this with the empty echo “”

I think it might be the first line that is the problem but dont know why. If anyone can help me it would be much appreciated.

Regards
Ross.

semicolon is missing after else echo

Otherwise there’s no problem in your code and i think it should work. If it doesn’t, then let me know.

thanks for that, I did as you said:

<?php $pdf = $row_getProducts['part_pdf']; if ($pdf == "NULL") { echo "test"; } else echo ""; ?>

still gives nothing, it is as if it is not checking the part_pdf from the database, if I remove this and replace with a basic “xxxx” comparison it works.

I have no idea why it wont work.

while comparison with null we don’t put quotes " ". If you do so it will consider as a string instead of null

So, try this:

[php]<?php
$pdf = $row_getProducts[‘part_pdf’];
if ($pdf == NULL) {
echo “test”;
}
else echo “”;
?>[/php]

I think that has done the trick! thank you very very much! i knew it had to be somthing simple but couldn’t put my finger on it.

Sponsor our Newsletter | Privacy Policy | Terms of Service