/    Sign up×
Community /Pin to ProfileBookmark

phpbb news with poll

hello,

i get a good phpbb script from somewhere

i am trying to create one code that output a thread with poll or a thread without poll

for example

if the script read
topic_vote=0 then that means not display threads with poll so display normal thread only
or
topic_vote=1 then that means display threads with poll only so normal thread will not display.

i want like this but i dont know if it works or not

[code=php]
<?php
$server = “localhost”;
$database = “forums”;
$user = “root”;
$password = “password”;
$forum_id = “10”; # the news forum id

$link = mysql_connect($server, $user, $password) or die(“Could not connect”);
mysql_select_db($database, $link) or die(“Could not select database”);

$query = “SELECT * FROM `phpbb_topics` WHERE `forum_id` = ‘$forum_id’ ORDER BY `topic_time` desc LIMIT 5”; //Change limit to number of news to get
$result = mysql_query($query, $link) or die(“Query failed”);

while ($row = mysql_fetch_array($result))
{
$topics[]=$row;
}

mysql_free_result($result);

foreach ($topics as $topic)
{
$topic_id = $topic[‘topic_id’];
$query = “SELECT * FROM `phpbb_posts` WHERE `topic_id` = ‘$topic_id’ ORDER BY `post_time` ASC”;
$result = mysql_query($query, $link) or die(“Query failed”);
$posts[] = mysql_fetch_array($result);
$count[] = mysql_num_rows($result)-1;
mysql_free_result($result);
}

foreach ($posts as $post)
{
$post_id = $post[‘post_id’];
$query = “SELECT * FROM `phpbb_posts_text` WHERE `post_id` = ‘$post_id'”;
$result = mysql_query($query, $link) or die(“Query failed”);
$posts_text[] = mysql_fetch_array($result);
mysql_free_result($result);
}

foreach ($posts as $post)
{
$user_id = $post[3];
$query = “SELECT * FROM `phpbb_users` WHERE `user_id` = ‘$user_id'”;
$result = mysql_query($query, $link) or die(“Query failed”);
$users[] = mysql_fetch_array($result);
mysql_free_result($result);
}

$query=”SELECT * FROM `phpbb_topics ` WHERE `topic_vote`”;
$res=mysql_query($query,$link);

if ( $res[“topic_vote”] == 1 ) {

$i=0;
foreach ($topics as $topic)
{
$post = $posts[$i];
$post_text = $posts_text[$i];
$user = $users[$i];
$posttext = nl2br($post_text[‘post_text’]);
$posttext = preg_replace(“/([quote:(.*?)])/”, “<i><b>Quote:</b></i><blockquote>”, $posttext);
$posttext = str_replace(“[/quote]”, “</blockquote>”, $posttext);
$posttext = preg_replace(“/([(.*?)])/i”, “”, $posttext);
$posttext = explode(” “, $posttext);
$date = gmdate(“D M d, Y g:i a”, $post[4]);
$content .= “<table width=”100%” cellspacing=”0″ cellpadding=”3″>n”;
$content .= “<tr>n<td style=”border:1px solid #666666;”>n”;
$content .= “<b>Posted by ” . $user[‘username’] . ” on $date GMT</b><br/>n”;
$content .= “<b>Subject: ” . $topic[‘topic_title’] . “</b></td></tr>n”;
$content .= “<tr><td style=”border:1px solid #666666;”>”;
if (count($posttext) > 100) {
for ($x = 0; $x < 100; $x++) {
$content .= $posttext[$x] . ” “;
}
$content .= “…”;
} else {
$content .= $post_text[‘post_text’];
}
$content .= “</td></tr>n”;
$content .= “<tr><td style=”border:1px solid #666666;”><a href=”forum/viewtopic.php?t=” . $topic[‘topic_id’] . “” target=”_blank”>”;
if (count($posttext) > 100) {
$content .= “Read More…<br>”;
}
$content .= “Replies: ” . $count[$i] . “</a>n”;
$content .= “</td>n</tr>n”;
$content .= “</table><br><br>n”;
$i++;
$posttext = “”;
}

} else {
echo “its not working1”;
}

mysql_close($link);

$content .= “<br>”;

echo $content;
?>
[/code]

anyway it doesn’t work so please help me… thank you very much

[upl-file uuid=abfdd7d3-39f4-4434-aeb1-69c9df3e13d4 size=85kB]topic_vote.jpg[/upl-file]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @cma spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...