Example:// http://walkinginchrist.org/vintage/practice.php?id=4 // When you click the link to the comments, it shows another post not the one you would be reading.
index.php
CODE
<?php
mysql_connect ('****', '****', '****');
mysql_select_db ('****');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid ID specified.");
}
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog WHERE id='$id' LIMIT 1";
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog ORDER BY timestamp DESC LIMIT 1";
$result = mysql_query($sql) or print ("Can't select entry from table blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y g:ia", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$listening = stripslashes($row['listening']);
$reading = stripslashes($row['reading']);
$quote = stripslashes($row['quote']);
?>
<div class="div" id="content">
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td valign="top"><img src="http://www.walkinginchrist.org/vintage/nav/1/images/welcome_avatar.gif" alt="welcome button"></td>
<td valign="top" class="div"><br>Hello and welcome to Vintage Heart Online-- my online zine. Located here are my personal opinions on various subjects along with poems, short stories and personal graphics.<br><br>
Please feel free to browse the site, and link me if you wish. Please note that this Zine is not meant to be the ranting's of a Radical Leftist, but the unjudgemental, personal views of myself.<br>
<br>
<p align="right"><a href="#">What pray tell is a Zine ?</a></p></td>
</tr>
</table>
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="entryheader"><?php echo $title; ?></td>
</tr>
<tr>
<td class="entrysub"><?php echo $date; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Reading:</strong> <?php echo $reading; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Listening To:</strong> <?php echo $listening; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Quote:</strong> <?php echo $quote; ?></td>
</tr>
<tr>
<td class="entry"><br><?php echo $entry; ?></td>
</tr>
</table>
<?php
$result2 = mysql_query ("SELECT id FROM blog_comments WHERE entry='$id'");
if ($num_rows > 0) {
echo "<a href=\"entry.php?id=" . $id . "\">" . $num_rows . " comments</a>";
}
else {
echo "<a href=\"entry.php?id=" . $id . "\">Leave a comment</a>";
} ?>
</p>
<?php
}
?>
mysql_connect ('****', '****', '****');
mysql_select_db ('****');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid ID specified.");
}
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog WHERE id='$id' LIMIT 1";
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog ORDER BY timestamp DESC LIMIT 1";
$result = mysql_query($sql) or print ("Can't select entry from table blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y g:ia", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$listening = stripslashes($row['listening']);
$reading = stripslashes($row['reading']);
$quote = stripslashes($row['quote']);
?>
<div class="div" id="content">
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td valign="top"><img src="http://www.walkinginchrist.org/vintage/nav/1/images/welcome_avatar.gif" alt="welcome button"></td>
<td valign="top" class="div"><br>Hello and welcome to Vintage Heart Online-- my online zine. Located here are my personal opinions on various subjects along with poems, short stories and personal graphics.<br><br>
Please feel free to browse the site, and link me if you wish. Please note that this Zine is not meant to be the ranting's of a Radical Leftist, but the unjudgemental, personal views of myself.<br>
<br>
<p align="right"><a href="#">What pray tell is a Zine ?</a></p></td>
</tr>
</table>
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="entryheader"><?php echo $title; ?></td>
</tr>
<tr>
<td class="entrysub"><?php echo $date; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Reading:</strong> <?php echo $reading; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Listening To:</strong> <?php echo $listening; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Quote:</strong> <?php echo $quote; ?></td>
</tr>
<tr>
<td class="entry"><br><?php echo $entry; ?></td>
</tr>
</table>
<?php
$result2 = mysql_query ("SELECT id FROM blog_comments WHERE entry='$id'");
if ($num_rows > 0) {
echo "<a href=\"entry.php?id=" . $id . "\">" . $num_rows . " comments</a>";
}
else {
echo "<a href=\"entry.php?id=" . $id . "\">Leave a comment</a>";
} ?>
</p>
<?php
}
?>
entry.php
CODE
<?php
mysql_connect ('****', '****', '****');
mysql_select_db ('****');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid ID specified.");
}
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog WHERE id='$id' LIMIT 1";
$result = mysql_query($sql) or print ("Can't select entry from table blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y g:ia", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$listening = stripslashes($row['listening']);
$reading = stripslashes($row['reading']);
$quote = stripslashes($row['quote']);
?>
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="entryheader"><?php echo $title; ?></td>
</tr>
<tr>
<td class="entrysub"><?php echo $date; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Reading:</strong> <?php echo $reading; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Listening To:</strong> <?php echo $listening; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Quote:</strong> <?php echo $quote; ?></td>
</tr>
<tr>
<td class="entry"><br><?php echo $entry; ?></td>
</tr>
</table>
<br><br><br>
<?php
}
$commenttimestamp = strtotime("now");
$sql = "SELECT * FROM blog_comments WHERE comentry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table blog_comments.<br />" . $sql . "<br />" . mysql_error());
?>
<?php
while($row = mysql_fetch_array($result)) {
$timestamp = date("l F d Y @ g:ia", $row['timestamp']);?>
<?php print("<p>" . stripslashes($row['comment']) . "</p>");?>
<?php printf("<p>Comment by <a href=\"%s\">%s</a> on %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
}
?>
<form method="post" action="process.php">
<p><input type="hidden" name="comentry" id="comentry" 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>
mysql_connect ('****', '****', '****');
mysql_select_db ('****');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid ID specified.");
}
$id = (int)$_GET['id'];
$sql = "SELECT * FROM blog WHERE id='$id' LIMIT 1";
$result = mysql_query($sql) or print ("Can't select entry from table blog.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$date = date("l F d Y g:ia", $row['timestamp']);
$title = stripslashes($row['title']);
$entry = stripslashes($row['entry']);
$listening = stripslashes($row['listening']);
$reading = stripslashes($row['reading']);
$quote = stripslashes($row['quote']);
?>
<table width="370" border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="entryheader"><?php echo $title; ?></td>
</tr>
<tr>
<td class="entrysub"><?php echo $date; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Reading:</strong> <?php echo $reading; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Currently Listening To:</strong> <?php echo $listening; ?></td>
</tr>
<tr>
<td class="entrysub"><strong>Quote:</strong> <?php echo $quote; ?></td>
</tr>
<tr>
<td class="entry"><br><?php echo $entry; ?></td>
</tr>
</table>
<br><br><br>
<?php
}
$commenttimestamp = strtotime("now");
$sql = "SELECT * FROM blog_comments WHERE comentry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table blog_comments.<br />" . $sql . "<br />" . mysql_error());
?>
<?php
while($row = mysql_fetch_array($result)) {
$timestamp = date("l F d Y @ g:ia", $row['timestamp']);?>
<?php print("<p>" . stripslashes($row['comment']) . "</p>");?>
<?php printf("<p>Comment by <a href=\"%s\">%s</a> on %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
}
?>
<form method="post" action="process.php">
<p><input type="hidden" name="comentry" id="comentry" 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>