Reputation: 18
I have this HTML/CSS here:
<div class="liste">
<div class="content">
<h4>Cyekl something</h4>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores, ullam, consectetur, totam vel consequuntur
quas sunt nulla rerum maxime saepe repudiandae voluptate porro laudantium repellat rem non doloremque? Ea,
delectus, quis quod nemo deleniti velit
</p>
</div>
<div class="listeimage">
<img src="http://lorempixel.com/116/80/" alt="">
</div>
<p class="pris">Pris 9.995 kr.</p>
<a href="#">
<h4 class="mereinfo">Mere info</h4>
</a>
</div>
and when I'm using it with PHP, the sidebar I have on my page moves into the content class and just kinda ruins everything.
$cykel_id = $row['cykel_id'];
$cykel_tekst = $row['cykel_tekst'];
$cykel_pris = $row['cykel_pris'];
$img = 'http://lorempixel.com/116/80/';
echo '<div class="liste"><div class="content"><h4>'.$cykel_id.'</h4>'.'<p>'.$cykel_tekst.'</p>'.'</div><div class="listeimage"><img src="'.$img.'"</div><p class="pris">'.$cyke_pris.'</p>'.'<a href="#"><h4 class="mereinfo">Mere info</h4></a></div>';
}
And thats my php code I have no idea what's going wrong hope someone can help me.
Upvotes: 0
Views: 46
Reputation: 10627
You didn't close your img
tag. Also, you had a typo at $cyke_pris
. It should be $cykel_pris
. The following format may help you avoid this error in the future:
<?php
$cykel_tekst = $row['cykel_tekst'];
$cykel_pris = $row['cykel_pris'];
$img = 'http://lorempixel.com/116/80/';
echo "<div class='liste'>
<div class='content'>
<h4>$cykel_id</h4>
<p>$cykel_tekst</p>
</div>
<div class='listeimage'>
<img src='$img' />
</div>
<p class='pris'>$cykel_pris</p>
<a href='#'><h4 class='mereinfo'>Mere info</h4></a>
</div>";
?>
You can use output buffering to get rid of tho white spaces, or just take them out yourself.
Upvotes: 0
Reputation: 8706
Indent your code properly and you will see the mistakes much faster.
After formatting, your PHP echo
looks like this:
echo '
<div class="liste">
<div class="content">
<h4>'.$cykel_id.'</h4>
'.'<p>'.$cykel_tekst.'</p>'.'
</div>
<div class="listeimage">
<img src="'.$img.'"
</div>
<p class="pris">'.$cyke_pris.'</p>
'.'
<a href="#">
<h4 class="mereinfo">Mere info</h4>
</a>
</div>
';
The <img />
tag is not closed properly.
Also, there are some unnecessary '.'
fragments here and there, but they are not affecting the correctness.
The line with img
tag should look like:
<img src="'.$img.'" />
(and to be fully valid, it should have alt
attribute, too)
Upvotes: 1