Jump to content

div inside php script?


tml

Recommended Posts

my problem is, i cant put my div into my script without break it and then rest wont work...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>

<head>

<title>vores hjemmeside</title>

<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div id="side">

  <div id="hoved"><img src="billed/banner.jpg">

 

  </div>

  <div id="links">

  <center>

<a href="index.php">Forside</a>  

<a href="index.php?side=os">os</a>  

<a href="index.php?side=kira">kira</a>  

<a href="index.php?side=billeder">billeder</a>  

  </center>

  </div>

  <div id="indhold">

 

<?php

 

if ($_GET['side'] == os)

{

echo "os";      //indhold af side 1

}

 

elseif ($_GET['side'] == kira)

{

    //indhold af side 2

 

 

}

elseif ($_GET['side'] == billeder)

{

 

// here are the problem when i try inset this div

 

<div id="billedmenu">

 

<a href="index.php?side=kira">kira</a>

 

</div>

 

<div id="billedindhold" class="clear">

mysql_connect("localhost", "xx", "xx") or die(mysql_error());

mysql_select_db("xx") or die(mysql_error());

 

$query = mysql_query("SELECT * FROM billed ORDER BY id DESC");

while($row = mysql_fetch_assoc($query))

{

echo "<a href='{$row["sti"]}'><img src='{$row["lille"]}' class='foto' border='0' /></a>";

}

</div>

}

else echo "hej"; //forside

?>

</div>

 

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/128863-div-inside-php-script/
Share on other sites

echo the divs out.

 

or just end your code with ?> before the div and start it again <?php after it

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>vores hjemmeside</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="side">
   <div id="hoved"><img src="billed/banner.jpg">

   </div>
   <div id="links">
   <center>
<a href="index.php">Forside</a>  
<a href="index.php?side=os">os</a>  
<a href="index.php?side=kira">kira</a>  
<a href="index.php?side=billeder">billeder</a>  
   </center>
  </div>
  <div id="indhold">

<?php

if ($_GET['side'] == os)
{
echo "os";       //indhold af side 1
}

elseif ($_GET['side'] == kira)
{
     //indhold af side 2


}
elseif ($_GET['side'] == billeder)
{
//If you have several lines, it's usually easier to pause/resume PHP
?>

<div id="billedmenu">

<a href="index.php?side=kira">kira</a>

</div>

<div id="billedindhold" class="clear">
<?php
mysql_connect("localhost", "xx", "xx") or die(mysql_error());
mysql_select_db("xx") or die(mysql_error());

$query = mysql_query("SELECT * FROM billed ORDER BY id DESC");
while($row = mysql_fetch_assoc($query))
{
echo "<a href='{$row["sti"]}'><img src='{$row["lille"]}' class='foto' border='0' /></a>";
}
//For one line, just use echo
echo '</div>';
}
else echo "hej"; //forside
?>
</div>


</body>
</html> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.