Jump to content

How Can You Generate Html Based Upon Php Code?


snyderm
 Share

Recommended Posts

Is it possible to have PHP scripting activate HTML code based on certain conditions?For instance, say I wanted a web page to display a certain picture based upon a variable contained in a file.In my case, I want to display a picture that conveys information about the weather outside. If the wind is currently blowing to the east, I want to display a picture that indicates the wind is blowing to the east.I am reading my weather data from a file, and storing that informations in variables to be displayed in a table. But the problem is that the only interaction I know of between php and my html code is the ECHO function.For instance to display the current temperature in a web page table cell, all I have to do is:<td><?php echo "$myweatherarray[1]" ?></td>but how do I display a picture with html code based upon a variable? As far as I am aware of, this is against the rules.example:<?php if ($myweatherarray[1] > 34) <img src = "pictureofwindblowing.bmp">;else <img src = "pictureofcalmwind.bmp">;?>How can I display HTML code inside of a php block? Is this possible?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...