PDA

View Full Version : PHP and DivTags


m1a2x3x7
07-03-2007, 06:40 PM
Some might know I've been creating a blog site in m spare time for php practice. Well I'm a CSS guy and don't care to much for tables. Well for my blogs I use a table in a while loop. I want to lose the table and use straight CSS.

code

<?php do { ?>
<tr>
<td width="385" class="blog_title"><?php echo $row['title'];?></td>
</tr>
<tr>
<td class="date"><?php echo $row['date'];?></td>
</tr>
<tr>
<td class="blog"><?php echo nl2br($row['blog']);?></td>
</tr>
<tr>
<td class="blog">.................................................. .................................................. ....</td>
</tr>
<tr>
<td><input name="comment" type="button" value="Comment" id="Comment" onClick="document.location.href='comment.php?comment=<?php echo $row['blog_id'];?>'"/></td>
</tr>
<tr>
<td class="blog">.................................................. .................................................. ....</td>
</tr>
<?php } while ($row = mysql_fetch_array($result));
?>

Now since you can't use the same DivTag twice I'm not sure how I can loop this.

Any help would be great.


Thanks in advanced David :wink::grin:8-)

domedia
07-03-2007, 06:44 PM
You can use the same div tags as many times as you want 8)
<?php do { ?>
<div><?php echo $row['title'];?></div>
<div><?php echo $row['date'];?></div>
<div><?php echo nl2br($row['blog']);?></div>
<input name="comment" type="button" value="Comment" id="Comment" onClick="document.location.href='comment.php?comme nt=<?php echo $row['blog_id'];?>'"/>
<?php } while ($row = mysql_fetch_array($result));
?>

If you need to assign CSS to each div, use a class, as in:
<div class="post-title"><?php echo $row['title'];?></div>
<div class="post-date"><?php echo $row['date'];?></div>
etc

m1a2x3x7
07-03-2007, 06:59 PM
BAHHHHHH....yeah i just tested it and found out you can. Hmmm learn something new everyday. for the longest time I thought you could only use a tag once. Kinda a nice thing to know.

thanks domedia

domedia
07-03-2007, 07:11 PM
Hey glad I could help 8)

some tags can only be used once, but they're part of the main html structure like TITLE, HTML, HEAD and BODY.