PDA

View Full Version : I need some PHP help



s9722
12-10-2006, 04:04 PM
Ok, I am looking to display popular forum threads on the main page of my website, I don't really know anything about php so if anybody has an easy way of doing this that would be great.

thetestingsite
12-10-2006, 04:29 PM
A few questions.

1) Do you want to display the most popular (ie: most viewed), or the newest ones?

2) Does your forum use a database or does it use a flat file format (text files to store data)?

3) What forum do you use (PHPBB, IPB, FlexxBB, etc)?

If you want to view the most popular (depending on the forum you use) and it uses a database, you should simply be able to display the ones with the most views. To get started you could use the following (assuming you use MySQL):

test.php


<?php
//change the following
$server = "localhost"; //the database server
$username = "testing"; //the database username
$password = "testing"; //the database password
$db = "forum"; //the forum database


$conn = mysql_connect($server, $username, $password); //makes the connection

mysql_select_db($db); // selectes the database

$threads = mysql_query("SELECT * FROM `threads` ORDER BY `views` DESC LIMIT 0, 10");

/* gets the list of threads with the most views starting with the most views and only show 10 */

echo '<ul>';

while ($q = mysql_fetch_array($threads)) { /* assigns a variable for the mysql array */

echo '<li><a href="threaddisplay.php?id='.$q[id].'">'.$q[title].'</a></li>
'; //display the thread title and url to the thread

}

echo '</ul>'; //end the list.
?>


Hope this helps you get started.

chovy
12-11-2006, 12:18 AM
most likely there is a mod for your forum already out there.

GhettoT
12-11-2006, 12:22 AM
most likely there is a mod for your forum already out there.

Yes, most forum softwares have some sort of MOD/hack called a "portal" that simply shows the latest/most viewed those should be easily modified to fit your needs.

s9722
12-11-2006, 11:32 PM
I am using phpbb and its on a free server, as a matter of fact I don't even know if I can transfer the forum... anybody know anything about this?
http://www.hostingphpbb.com/

djr33
12-12-2006, 12:56 AM
Well, you'd need access to the database and move that info to a new server. If you have it, then it's possible. If not, then it's not. Just that simple.

s9722
12-13-2006, 02:05 PM
Well, it looks like the answer is no then doesn't it...:|

djr33
12-14-2006, 04:29 AM
You could try to go in and get access through the Admin CP. I really have no idea about their security/TOS, so not sure.

Aside from that, I did the same thing....just start over, and do it asap, so you lose the least possible.

chovy
12-14-2006, 04:01 PM
You have to have access for the forum to work. Even if you can't directly log in, you could still write a script to export the tables.