Topic: Only first post on each page visible after adding a PHP-Code
Hi out there.
I was thinking about a way to rate postings. So, this wasn't really difficult, only add some lines at the bottom of each post, that would do.
It actually did. I created a table named "forum2_votes". And I added the following code in viewtopic.php (line 336 or around):
<div class="postfootright">
<?php
//Positive Bewertungen zählen - Count positive ratings
$sql="SELECT * FROM `forum2_votes` WHERE `vote`='1' AND `for_post`='".$cur_post['id']."'";
$result = $db->query($sql);
$num_pos = $db->num_rows($result);
//Negative Bewertungen zählen - Count negative ratings
$sql="SELECT * FROM `forum2_votes` WHERE `vote`='2' AND `for_post`='".$cur_post['id']."'";
$result = $db->query($sql);
$num_neg = $db->num_rows($result);
if(count($post_actions)){
echo "<span class=\"bewerten\">\n";
echo " <span>Bewertungen: ".$num_pos."+, ".$num_neg."-</span><br>\n";
echo " <span>Post bewerten: <a href=\"vote.php?vote=1&pid=".$cur_post['id']."&user=".$pun_user['username']."\">positiv</a> - <a href=\"vote.php?vote=2&pid=".$cur_post['id']."&user=".$pun_user['username']."\">negativ</a></span>\n";
echo "</span>\n";
echo "<ul>".implode($lang_topic['Link seperator']."</li>", $post_actions)."</li></ul></div>\n";
}
else{
echo "<div> </div></div>\n";
}
// echo (count($post_actions)) ? '<ul>'.implode($lang_topic['Link separator'].'</li>', $post_actions).'</li></ul></div>'."\n" : '<div> </div></div>'."\n"
?>
Okay, there really is no problem in making some simple security-scans and a SQL-string to insert the voting into the table. This was all stuff for the vote.php.
But now - and incomprehensible - viewtopic.php shows me only the first posting on each page, and gulps the rest. The line with the // was the original (now it may be easyier for you to find the line).
Does anyone see the mistake? I don't, even after I sat on it for hours and recognized that it was already half past 3 in the night (here in Germany)
Now, my board is well-visited, and often-looked-at. I would be very thankful for a quick and simple solution, because I can't leave it like this.
Best wishes and greetings from Germany
Adri
(Excuse me for the mistakes I wrote here, I did not speak or write English for months)
BTW: How can I create syntax-highlighting [ code ]-blocks?