views:

48

answers:

2

Creating a blog from scratch is a difficult process but I've been plodding along with some minor issues which have been resolved. My minor issue today is the fact that I'm unable to style the site background with an image. I'm able to add colors but not an image.

The second minor issue is to do with my Div tags. I've created a basic form that submits comments to my MySQL database but when I attempt to style the div that I've enclosed the form and comments that are displayed the styles have not appeared. I have included my Comments CSS below and my post.php page.

CSS:

#comments-title {
    background-color: #282828;
    width: 567px;
    height: 30px;
    font-size: 25px;
    font-family: arial;
    color: #ffffff;
    padding: 5px;
    padding-top: 6px;
    padding-bottom: 4px;
}


#comment-list{
    border:1px solid #dadada;
    width: 567px;
    padding: 5px;
}

PHP:

<h2 id="comments-title">Comments</h2>
 <div id="comment-list'">
    <?php

}
$commenttimestamp = strtotime("now");

$sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
    $timestamp = date("l F d Y", $row['timestamp']);
    print("<p id='comment'>" . stripslashes($row['comment']) . "</p>");
    printf("<p id='comment'>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
}
?>


<form method="post" action="process.php">

<p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" />

<input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>">

<strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="25" /><br />

<strong><label for="email">E-mail:</label></strong> <input type="text" name="email" id="email" size="25" /><br />

<strong><label for="url">URL:</label></strong> <input type="text" name="url" id="url" size="25" value="http://" /><br />

<strong><label for="comment">Comment:</label></strong><br />
<textarea cols="25" rows="5" name="comment" id="comment"></textarea></p>

<p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /></p>

</form>
</div>
+1  A: 

Remember that the ID have to be unique. use class instead if id. (In your while loop: <p id='comment'>, you have multiple id's with the same id.

You have a lot of this to fix.

And, try to validate your code to check for some errors that might prevent it from working. http://validator.w3.org + You have a single quote in your comment-list ID

Terw
That didn't fix anything.
ThatMacLad
However, MacLad, he is correct. You don't ever want to repeat "ids" or you will quickly run into headaches (and rightfully so..an id is supposed to be a unique identifier). If you want to apply a specific style across multiple elements, you'll want to use CSS classes.
treeface
Have you tried validating your code? 3 errors just in that part you have above
Terw
I renamed the offending ids. I have different ids for them. I'll check my code now and get back to you.
ThatMacLad
+3  A: 

Take a second look at this line:

<div id="comment-list'">

See that little ' in there? Take it out.

For everything else, you're going to have to be more specific. You've basically posted a large slab of code here without pointing to the offending code.

treeface
I've already edited it to remove the majority of the code.
ThatMacLad
It worked. I can't believe I didn't spot that.
ThatMacLad