I'm trying to create some basic PHP code which will change the commercial on my front page of my site and have a different commerical for each day of the week (site is www.niksmilitarysales.com )
Now I had a code to do this for days of the week, and heres the days of the week I used.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<p>
<!-- PHP CODE DAY CODE -->
<?php
$d=gmdate("D",time()+3600); // GMT+1 --> 3600 seconds
if ($d=="Fri")
echo "Enjoy your weekend!";
elseif ($d=="Sat")
echo "Enjoy your Saturday!";
elseif ($d=="Sun")
echo "Enjoy your Sunday!";
elseif ($d=="Mon")
echo "Enjoy your Monday!";
elseif ($d=="Tue")
echo "Enjoy your Tuesday!";
elseif ($d=="Wed")
echo "Enjoy your Wednesday!";
elseif ($d=="Thu")
echo "Enjoy your Thursday!";
?> </p>
<body>
</body>
</html>
This code is what I intended up with (I just copied the same video over several different times.
Thank you for your response, but that code COMPLETELY screws up my entire page.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<?php include 'headerarea4.php' ?><head><title>Nik's Military Military Car Sales</title>
This is my main page code.
<div id="content">
<marquee direction="left" loop="20"><a href="truckoftheyear.php" target="_blank"><font size="4" color="#0B0000">Click here to see who won Truck Of The <strong>YEAR!</strong></font></a></marquee>
<p><h3>Welcome to Nik's Military Military Car Sales</h3> <!-- Remember this is in order to keep the names of the various site owners and their respective agents in check, in order to reduce the likely hood of a crossover --><?php include 'fullagent.php' ?> is a independent sales agents representing Exchange New Car Sales in the Balkans</p>
<p>We are on base to serve those who serve; with years of sales experience. We firmly believe in sound customer service and would like for you to experience that. Therefore stop by the office. Or if it’s easier for you just give us a call or send us an e-mail by going to our <a href="contactus.php">contact page.</a> </p>
<p>Exchange New Car Sales has been serving the military community since the mid 1960s when AAFES/NEXCOM program was authorized by the U.S. Congress.
We make sure you are able to purchase a US made Ford, Chrysler or Harley regardless of where you are stationed, at a fair price with choice and wonderful customer service.</p>
<p>
<!-- PHP CODE DAY CODE -->
<?php
$d=gmdate("D",time()+3600); // GMT+1 --> 3600 seconds
if ($d=="Fri")
echo "Enjoy your weekend!";
elseif ($d=="Sat")
echo "Enjoy your Saturday!";
elseif ($d=="Sun")
echo "Enjoy your Sunday!";
elseif ($d=="Mon")
echo "Enjoy your Monday!";
elseif ($d=="Tue")
echo "Enjoy your Tuesday!";
elseif ($d=="Wed")
echo "Enjoy your Wednesday!";
elseif ($d=="Thu")
echo "Enjoy your Thursday!";
?>
<!-- END OF PHP DAY CODE -->
</p>
<?php
// Array of week days. Replace links accordingly
$ads[0] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // Sunday
$ads[1] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // M
$ads[2] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // T
$ads[3] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // W
$ads[4] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // T
$ads[5] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // F
$ads[6] = 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'; // Saturday
$d = gmdate("w", time()+3600); // This returns the numeric day of the week. 0 for Sunday and 6 for Saturday
$ad_today = $ads[$d];
?>
<p><a href="mustang.php" target="_blank"><p align="center" ><h1 align="center" style="color:black"><u>Introducing the 2010 Mustang</u></h1></p></a>
<p align="center"><object width="480" height="295"><param name="movie" value="<?php echo $ad_today; ?>"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<?php echo $ad_today; ?>" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object> <?php include 'videocode.php' ?></table></p>";
</p>
<p align="center"><h2 align="center">NEWS</h2></p>
<p align="center"><a href="carnews.php"><h3 align="center">Click here for the latest on up to date car news!</h3></a></p>
<a href="www.firefox.com" target="_blank"><h3 align="center" style="color:orange">THIS SITE BEST VIEWED IN FIREFOX</h3>
<center><img src="../pics/firefox.jpg" align="middle" width="36" height="35" border="none"><p>FIREFOX</p></center></a>
<!-- end of page content -->
</div>
<div id="headerbar"><span class="largeaccentbold">Nik's Military New Car Sales - </span></div>
<div id="footer4"><?php include 'footer.php' ?></div>
<div id="Layer1">
<?php include 'rightside.php' ?>
</div>
</div>
<div class="featurelink" id="lojackdetails"><a href="../PDFs/lojack.pdf"">LoJack™ is here! Click for more details...</a></div>
<img src="../pics/banner/editing needed2 copy.jpg" width="932" height="214"></div></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<?php include 'headerarea4.php' ?><head><title>Nik's Military Military Car Sales</title>
<div id="content">
<marquee direction="left" loop="20"><a href="truckoftheyear.php" target="_blank"><font size="4" color="#0B0000">Click here to see who won Truck Of The <strong>YEAR!</strong></font></a></marquee>
<p><h3>Welcome to Nik's Military Military Car Sales</h3> <!-- Remember this is in order to keep the names of the various site owners and their respective agents in check, in order to reduce the likely hood of a crossover --><?php include 'fullagent.php' ?> is a independent sales agents representing Exchange New Car Sales in the Balkans</p>
<p>We are on base to serve those who serve; with years of sales experience. We firmly believe in sound customer service and would like for you to experience that. Therefore stop by the office. Or if it’s easier for you just give us a call or send us an e-mail by going to our <a href="contactus.php">contact page.</a> </p>
<p>Exchange New Car Sales has been serving the military community since the mid 1960s when AAFES/NEXCOM program was authorized by the U.S. Congress.
We make sure you are able to purchase a US made Ford, Chrysler or Harley regardless of where you are stationed, at a fair price with choice and wonderful customer service.</p>
<p>
<!-- PHP CODE DAY CODE -->
<?php
$d=gmdate("D",time()+3600); // GMT+1 --> 3600 seconds
if ($d=="Fri")
echo "Enjoy your weekend!";
elseif ($d=="Sat")
echo "Enjoy your Saturday!";
elseif ($d=="Sun")
echo "Enjoy your Sunday!";
elseif ($d=="Mon")
echo "Enjoy your Monday!";
elseif ($d=="Tue")
echo "Enjoy your Tuesday!";
elseif ($d=="Wed")
echo "Enjoy your Wednesday!";
elseif ($d=="Thu")
echo "Enjoy your Thursday!";
?>
<!-- END OF PHP DAY CODE -->
</p>
<a href="mustang.php" target="_blank"><p align="center" ><h1 align="center" style="color:black"><u>Introducing the 2010 Mustang</u></h1></p></a>
<p align="center"><object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object> <?php include 'videocode.php' ?></p>
<p align="center"><h2 align="center">NEWS</h2></p>
<p align="center"><a href="carnews.php"><h3 align="center">Click here for the latest on up to date car news!</h3></a></p>
<a href="www.firefox.com" target="_blank"><h3 align="center" style="color:orange">THIS SITE BEST VIEWED IN FIREFOX</h3>
<center><img src="../pics/firefox.jpg" align="middle" width="36" height="35" border="none"><p>FIREFOX</p></center></a> </div>
<div id="headerbar"><span class="largeaccentbold">Nik's Military New Car Sales - </span></div>
<div id="footer4"><?php include 'footer.php' ?></div>
<div id="Layer1">
<?php include 'rightside.php' ?>
</div>
</div>
<div class="featurelink" id="lojackdetails"><a href="../PDFs/lojack.pdf"">LoJack™ is here! Click for more details...</a></div>
<img src="../pics/banner/editing needed2 copy.jpg" width="932" height="214"></div></td>
</tr>
</table>
</body>
</html>
landing is on the right track.
It's just that when the PHP echo statement was converted to HTML, some of the syntax formatting was not removed.
And using an array to store the different links is the best idea because it is very fast.
The only thing that was left out was the ability to also change the title.
You could use a multidimensional array for this task or two different arrays.
I chose to use two arrays, to keep it simple.
And another thing that landing may be right about is HTML errors.
I don't understand why you have a closing table tag nested amongst the <p> tags.
PHP Code:
<?php // Array of titles. Replace titles accordingly $ads_text = array('Introducing the 2010 Mustang', // Sunday 'Introducing the 2010 Mustang', // M 'Introducing the 2010 Mustang', // T 'Introducing the 2010 Mustang', // W 'Introducing the 2010 Mustang', // Th 'Introducing the 2010 Mustang', // F 'Introducing the 2010 Mustang'); // Saturday
// Array of links. Replace links accordingly $ads_link = array('http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // Sunday 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // M 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // T 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // W 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // Th 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1', // F 'http://www.youtube.com/v/gYqGSl4K6uE&hl=en&fs=1'); // Saturday
$d = gmdate("w", time()+3600); // This returns the numeric day of the week. 0 for Sunday and 6 for Saturday
And to be completely honest, I don't understand why you have any closing table tags anywhere in your document because you don't seem to have any tables.