Jump to content

php if statement in html page


mbodamer

Recommended Posts

Hi,

I am trying tomimic this functionality:

 

<?php if($listing['bedrooms']) : ?><b>Bedrooms:</b> <?php echo $listing['bedrooms'] ?><br/> <?php endif; ?>

 

that is on a working site but I do not have the variable defined yet. I have a program that generates tags like this: {bedrooms}

 

so I am seeking to match IF bedrooms=3 (for example) then display 3bed.jpg

 

this is what I was trying but it failed miserably:

 

<?php $name = {name};  if($name == "joe") : ?><img src="joe.jpg"><?php endif; ?>

 

hopefully you can follow my wayward logic.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/274123-php-if-statement-in-html-page/
Share on other sites

Well like I said... {name} is a tag that is generated from a program that I can simply put on the HMTL page anywhere and it will print the value of {name}. So I need a way to see what that value is, and then if it matches what I want, print something if not ignore it.

 

if I just put {name} on the page it will print "joe" for example.

Nope, it produces a syntax error for an unexpected {.

Easily testable by yourself, btw, by running one line via the PHP CLI shell.

 

Wow I was never aware we could run php from the command line. I was at work when I replied to that, usually I would just test something before asking a question etc.

 

So eunning PHP from the command line means we don't need a local server for example to run PHP scripts? I'm going to give the php.net a thorough read regarding CLI when I get back.

 

I might do a bit of PHP in my break now, they already got n++ installed ;D

 

Kind regards,

 

L2c.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.