how do i echo a value from php to html in a division (div2--a div i created) of a paragraph(p).
for example: i have a value called $greetings and i assign a value of "Welcome" to it
$greetings = "Welcome";
I tried:
`<p>
<?php
$index = "WELCOME";
echo "<div2>$index</div2>";
?>
</p>`
but it doesn't display the value of $greetings--welcome instead it displays ( $index"; ?> )
HERES MY ENTIRE CODE:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Tech Planet</title>
<link rel="stylesheet" type="text/css" href="style.css">
<img src="logo.gif" alt="logo" width="150" height="50">
<div class ='seachAndProducts'><form action="header.php" method="GET">
<input id="search" type="text" placeholder="Search Tech Planet...">
<input id="submit" type="submit" value="Search">
</form></div>
<div class = 'navAndFooter'><ul>
<li><a href="index.html"><b>Home</b></a></li>
<li><a href="test.php"><b>Products</b></a></li>
<li><a href=""><b>About</b></a></li>
<li><a href=""><b>Contact us</b></a></li>
</ul></div>
<a href="default.asp"><img src="cart.jpg" alt="cart" width="40" height="40"></a>
</head>
<body>
<h3><img src="WelcometoTechPlanet.gif" width="250" height="40"></h3>
<h5><div class ='ourAndFeatProductsHeader'>Our Products</div>
<div class='seachAndProducts'>
<a href=""><div class='ourProductsList'>Audio Systems</div></a>
<a href=""><div class='ourProductsList'>Cameras</div></a>
<a href=""><div class='ourProductsList'>Laptops</div></a>
<a href=""><div class='ourProductsList'>Memory Cards</div></a>
<a href=""><div class='ourProductsList'>Monitors</div></a>
<a href=""><div class='ourProductsList'>Phones</div></a>
<a href=""><div class='ourProductsList'>Televisions</div></a>
<a href=""><div class='ourProductsList'>USBs</div></a>
<a href=""><div class='ourProductsList'>All Products</div></a>
</div><div class ='ourAndFeatProductsHeader'>Featured Products</div>
<div2><img src="8wb50.gif" alt="" width="250" height="200"></div2></h5>
<p><?php
$index = "WELCOME";
echo "<h1>$index</h1>";
?></p>
<!-- used © because © displays © -->
<div class = 'navAndFooter'>© Tech Planet. All Rights Reserved.</div>
</body>
</html>
Here are a few things to note...
Don't put an h1 tag in the p tag; and you are echoing $index, not $greetings.
Try this
<?php
// Pick the one you want.
$greetings = "Welcome";
$index = "WELCOME";
// Pick the one you want
echo "<h1>$index</h1>";
echo "<h1>$greetings</h1>";
?>
Then, make sure you save it as a .php file, and that you are on a web server with php enabled.