> On Wed, Nov 12, 2008 at 11:55 AM, brucewhealton > wrote: > Hello all, > I thought this would be very easy but I'm doing something > wrong here. I want to create a display of an image using a variable. > In static html it is > <img src="images/topbanner1.jpg" /> > > I want the topbanner to change depending on the month of the year. > So, I calculate that with this, easy enough: > <?php > $monthnum = data("n"); > ?> > > I have six banners so I if $monthnum is greater than 6, I subtract 6. > This so far is very easy. > > Now, I want to build up the image tag using the php values. So, I > have the following (this is just the part of the code for displaying > the image. > > echo "<img src=\"images/topbanner"; > echo $monthnum."jpg"; > echo "\"/>"; > > I used the \ to escape the " on the first line where it should be > src="images/topbanner" > > What's wrong here? > Thanks, > Bruce > ------------------------------ try this echo "<img src='images/topbanner".$monthnum.".jpg'/>"; I hope it will help.
-- http://phpinterviewanswers.blogspot.com/