We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Title From SQL
Topic Started: Feb 17 2011, 06:00 PM (1,670 Views)
Karabox
Member Avatar
I am Iron Man.
[ *  *  * ]
So basically I'm writing my own forum script for personal use. It's not exactly easy for me because I'm a n00b at PHP. I'm not looking for posts saying "you should learn more about php/sql before you tackle such a big project?" though helpful comments are welcome.

I'm basically working on a page of the forum where I want my title to be the name of a forum (IE "General Talk"). Is there a way to do something like this?:

Code:
 
<?php $forum = mysql_query("SELECT * FROM Forum") or die(mysql_error()); $finfo = mysql_fetch_array( $forum);<title> Print ("".$finfo['forumname'] . " "); ?></title>


Much obliged.
Offline Profile Quote Post Goto Top
 
theTHIIIRD
Member Avatar
Member
[ * ]
Honestly before taking such a huge task as this, I would first find out how to do smaller ideas that are involved in a forum. Register/Log in system, pagination (such as Prev. 1 2 3 Next) , or just posting a comment. First of all before starting I would look at other scripts of forums. Such as http://www.chipmunk-scripts.com/board/index.php?forumID=43&ID=9268 for example. He has nice coding and take a look at the way he has started. Now it doesn't have categories, but after examining scripts it will become easier for you to do it yourself. PHP forums are difficult and take a while. I have built a couple, but believe me there is always something to add on to it after making one. After examining all that, I would then find a way to merge it with this register/log in system http://www.evolt.org/node/60384 . Once you have a register system and a way to create a topic and add replies with your name, you can find other ideas to do. Such as counting posts the member has made, putting an avatar system in it, and signature? Idk just random ideas. But I would definitely take a look at what your doing before you get the idea of making a forum.

-III
Offline Profile Quote Post Goto Top
 
Zefer
Member Avatar
Member
[ *  * ]
I'd have to agree with the above post. Without experience the forum script will be awful -- full of flaws, errors and loopholes you didn't know how to avoid.
Offline Profile Quote Post Goto Top
 
Minato-ZNS
Member Avatar
Someday the Dream Will End
[ *  *  * ]
I agree with them. Besides, the statement you got is basically set up to where it will kill the database. Variables are everything, especially in a global access. Because you would've used a sentence such as this.

Code:
 
$forum = mysql_query("SELECT fname FROM forum WHERE fid='$fid'");


And you'll have to get the forum name. I write mine like this.

Code:
 
$sql = mysql_query("SELECT * FROM forum WHERE fid='$fid'");
$row = mysql_fetchrow($sql);
$forumname = $row['fname'];


And then set $forumname into a global variable.
Offline Profile Quote Post Goto Top
 
slayer766
Member Avatar
Member
[ *  *  *  *  *  *  * ]
That's not how mysql_fetch_row works, that function returns a numerical array - which can only access the fields as $row[0], $row[1], $row[2] etc. which isn't something you should work with in this case but rather mysql_fetch_array which returns an associative array(or both) so you can access all the fields from the database such as $row['fname']
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply