aka ibebak
Paragon
Since so many out there want to, here is a simple tutorial.
I made this tutorial ages ago, over a year ago, it's very very very basic, I do not recommend that you actually use this code if you plan on building a software commercially, as some of it is very sloppy, outdated, and inefficient, but you could still learn a few things. This will only create a basic index page containing forums, and categories, I may post a more advanced tutorial later on.
Start off by creating your database file in order to connect to the mysql server
What the above code does is connect you to your database. If your settings are wrong it will display "Could not connect to MySQL", if they are right but there is no database in your account, you will see, "Database cannot be found." and it will kill the connection.
Next create your MySQL database tables.
My settings are below.
That is simply a database query. You may be able to use these settings to create an install file if needed. I will make an install file tutorial later on.
Next you will start your coding. I will not go very far in depth or even show you my entire code. Just the PHP/SQL parts. The html, you can do on your own.
Explanation: What this code is doing is connecting to the database and retrieving the information we specified and placing it into an html table.
This connects to your dbconnect file and then retrieves everything (*) from the cat table and order's them by the categories id (cid) in ascending order.
This does a very similar thing. The main difference is, it checks the forum.pid (parent id) field and displays any that have the same pid as any of the categories (cid) therefor simply connection the child (forum) with it's parent (category).
That was a simple php forum software tutorial.
I may go a bit more in depth later on but hopefully this helps a few people out.
Enjoy!
Styled Demo: *none, I deleted the files ages ago, this is an ancient tutorial.
I made this tutorial ages ago, over a year ago, it's very very very basic, I do not recommend that you actually use this code if you plan on building a software commercially, as some of it is very sloppy, outdated, and inefficient, but you could still learn a few things. This will only create a basic index page containing forums, and categories, I may post a more advanced tutorial later on.
Start off by creating your database file in order to connect to the mysql server
Code:
<?php
$mysql_host = "mysql";
$mysql_database = "DATABASE NAME HERE";
$mysql_user = "DATABASE USERNAME HERE";
$mysql_password = "PASSWORD HERE";
$connection = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die("Could not connect to MySQL");
mysql_select_db($mysql_database, $connection) or die ("Database cannot be found.");
?>
Next create your MySQL database tables.
My settings are below.
Code:
CREATE TABLE `cat` (
`cname` varchar(500) NOT NULL,
`cid` tinyint(99) NOT NULL AUTO_INCREMENT,
`cdesc` varchar(1000) NOT NULL,
PRIMARY KEY (`cid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `forum` (
`fname` varchar(200) NOT NULL,
`fid` tinyint(99) NOT NULL AUTO_INCREMENT,
`pid` tinyint(99) NOT NULL,
`fdesc` varchar(9999) NOT NULL,
PRIMARY KEY (`fid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `settings` (
`title` varchar(20) NOT NULL,
`online` tinyint(200) NOT NULL DEFAULT '1',
`offlinemsg` varchar(9999) NOT NULL DEFAULT 'We are sorry. The administrator of this forum has turned the board offline for mantinance, please check again later.',
KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Next you will start your coding. I will not go very far in depth or even show you my entire code. Just the PHP/SQL parts. The html, you can do on your own.
Code:
<?php
include ('dbconnect.php');
echo '<table>';
$cat = "SELECT * FROM cat ORDER BY cid asc";
$result = mysql_query($cat) or die(mysql_error());
while($catvar = mysql_fetch_array($result)){
echo '<tr><th colspan="1">'.$catvar['cname'].'<small> ( '.$catvar['cdesc'].' ) </small></th></tr>';
$forum = "SELECT * FROM forum WHERE forum.pid = ".$catvar['cid']." ORDER BY fid asc";
$result2 = mysql_query($forum) or die(mysql_error());
while($forumvar = mysql_fetch_array($result2)){
echo '<tr><td ><a href="./forum.php?='.$forumvar['fid'].'">'.$forumvar['fname'].'</a><br />'.$forumvar['fdesc'].'</td></tr>';
}
}
echo '</table>';
?>
Code:
$cat = "SELECT * FROM cat ORDER BY cid asc";
Code:
$forum = "SELECT * FROM forum WHERE forum.pid = ".$catvar['cid']." ORDER BY fid asc";
That was a simple php forum software tutorial.
I may go a bit more in depth later on but hopefully this helps a few people out.
Enjoy!
Styled Demo: *none, I deleted the files ages ago, this is an ancient tutorial.







