Jump to content

Count Comments :s


zackcez

Recommended Posts

ok i got it down to this code:

<?php
mysql_connect("db174.perfora.net", "dbo239605978", "NOPASS?") or die(mysql_error());
mysql_select_db("db239605978") or die(mysql_error());
if (isset($_GET['s'])) {
$search = $_GET['s'];
$query = "SELECT * FROM news WHERE id LIKE '%$search%' ORDER BY id DESC LIMIT 5";
$result2 = mysql_query("SELECT newsid FROM comments WHERE newsid='$row['id']'");
}
else {
$query = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
} 
$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result2);
while($row = mysql_fetch_array($result)){
echo "<div class=\"box\">";
echo "<a name=\"" . $row['name'] . "\"></a><h1><a href=\"index.html\">" . $row['title1'] . " <span class=\"white\">" . $row['title2'] . "</span></a></h1>";
echo "<p class=\"post-by\">Posted by <a href=\"index.html\">" . $row['auther'] . "</a></p>";
echo "<p>" . $row['story'] . "</p>";
echo "<p class=\"post-footer align-right\">";
echo "<a href=\"index.html\" class=\"readmore\">Read more</a>";
echo "<a href=\"index.html\" class=\"comments\">Comments ($count)</a></p>";
echo "</div>";
}
?>

That should be a bit closer to my problem...but i get an error yet:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/20/d239047801/htdocs/news.php on line 7

I know what the error means I just don't know any other way to use the code...

Link to comment
https://forums.phpfreaks.com/topic/97301-count-comments-s/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.