I am creating a dynamic page that is echoing a lot of divs
with a class and a unique id pulled from a database so they can be manipulated easily. I am unsure if I am doing it the best way or not it seems to be sloppy and hard to understand to me. I am hoping someone with more experience can help me figure out if there is a better way to accomplish the same thing. For example:
if ($comment['reply'] == 1) {
echo '<div class="comment">';
echo $comment['comment'];
echo "</div>";
echo '<BR /> <div class="replys" id="'.$comment['id'].'">';
echo '</div>';
echo '<div class="replyTo" id="'.$comment['id'].'reply">';
while ($replys = $stmt1->fetch(PDO::FETCH_ASSOC)) {
if ($replys['order_by'] % 2 == 0){
echo '<div class="replyToEven">';
echo $replys['reply'];
echo "</div>";
} else {
echo '<div class="replyToOdd">';
echo $replys['reply'];
echo "</div>";
}
}
The reason I have it echoing a div
is because I want all the contents to be in separate divs
, instead of one to separate the data from the MySQL query. Hopefully I have provided enough information just let me know if you need anymore.