--- [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > $number = 0 + date('n'); > if($number > 6) {$number = $number - 6;} > echo('<img src="images/topbanner' . $number > . '.jpg" />'); > > you were missing the . before jpg
Given the way that $number is used, it is probably not necessary to force it to be a number by adding zero. It's a good trick though. Here's another: $number = (date('n') % 6) + 1; The modulus (%) operator says divide by this number and return the remainder. Since we want values from 1..6 rather than 0..5, I add one to the result. The hard-coded 6 could be a variable with a count of the number of banner items you have so if you make more, they will be added to the loop. It's not very random, of course, but I think you knew that from the start. HTML will allow you to use single or double quotes around properties. However, when using print or echo, single quotes around the whole thing does not allow variable names to be replaced with their values. This will work: print "<img src='images/topbanner$number.jpg' />"; but it is a little hard to read. The printf() function is one worth mastering. Since we know we want a number, we can use %d as the substitution format placeholder. Normally %s is fine as well: printf("<img src='images/topbanner%d.jpg' />", $number); At all times, make your code easy to read. When you have to look at it again in 6 months, you'll appreciate readable code. Backslashes and excessive string concatenation can be hard to read and it is easy to miss a tiny piece of punctuation. James