1

I'm basically checking a users download limit in my database, and if their limit is < 1 I want to disable a input on my page.

<input type="text" name="link"<?php ($page["downloads_left"] < 1 ? " disabled=\"1\"" : ""); ?> />

When the page is run, the input is not disabled and I don't have any disabled="1" markup on my page. I have verified that $page["downloads_left"] is less than 1, and it is. It's 0.

Even when I add a string to be outputted if this IF statement evaluates false, it doesn't show in the markup.

Can anyone provide any help? Cheers.

Josh
  • 1,301
  • 5
  • 22
  • 33

4 Answers4

3

Don't forget the echo after <?php.

rid
  • 54,159
  • 26
  • 138
  • 178
3

You need to place an echo in the line:

<input type="text" name="link"<?php echo ($page["downloads_left"] < 1 ? " disabled=\"1\"" : ""); ?> />
Sean Walsh
  • 7,956
  • 2
  • 27
  • 38
1

You have to echo it

<?php echo ($page['downloads_left'] < 1) ? " disabled='1' " : ''?>
JohnP
  • 47,501
  • 10
  • 101
  • 134
1

<?php ($page...

should be

<?php echo ($page...

Amy B
  • 17,377
  • 12
  • 61
  • 81