![]() |
|
It's time to learn me stuff |
23yrold3yrold
Member #1,134
March 2001
![]() |
Okay, I just blasted through a reference of the PHP language and skimmed some MySQL docs. PHP is easy enough; reminds me of Lua. 1) I want to make some simple forums. I get the basic idea; user types info into an HTML forum, PHP script takes the info and stuffs it in a MySQL database, then retrieves it from said database when someone feels like reading the thread, right? I kind of need a basic outline on how I would go about organizing that though, since I get the feeling it's a little more complicated than that. I know there's plenty of guys here who have done this (not least of which is Matthew 2) Managing new content. Let's say I want to add news to the front page, or keep a gallery of images/artwork that I add to from time to time. Would that work a lot like, say, the IotD submission page is set up? I would make a page for my own personal use that would upload images and description, and it would be inserted into the gallery in some intelligent fashion? Sometimes I hear people talk about programs they use for adding news to their sites or something ... not sure if that's just my imagination ... I'm going to keep reading MySQL stuff now (if there's a good tut let me know), but I have other stuff to do today too (which is why I'm not on Battle.Net -- |
Kanzure
Member #3,669
July 2003
![]() |
1) I'm your guy. Please note, I haven't worked on 'mPort' - my content management system - in months. I'm working on something new of the likes, so let's not have everybody insult me at once for my crummy code |
Billybob
Member #3,136
January 2003
|
1) Start a table called "posts" with the following fields: that should be a basic setup, methinks. Sub Forum id would be the id of the form you're posting in (off-topic for example). Thread id is the id of the thread the post is in. post id is a unique id given to every post. Owner id is the member # of the poster. you know what the rest is. When you make that table, sub-forum id, thread id, and post id will probably be indexes. post id is unique. Post id also should be set to auto-increment. You'll also need tables to store information about threads, sub-forums (could combined with the general settings stuff as well), members, etc... Hope that helps some. and don't forget your htmlentities and addslashes
|
Kanzure
Member #3,669
July 2003
![]() |
Here's some more info. MySQL Snuff: database "bob" table posts id bigint 255 replyToId bigint 255 author varchar 255 text blob
<? mysql_connect("localhost", "root", ""); mysql_select_db("bob"); $sql = mysql_query("SELECT * FROM posts"); while($sr = mysql_fetch_array($sql)) { $id = $sr['id']; $replyId = $sr['replyToId']; $author = $sr['author']; $text = $sr['text']; print "<!--$id--><i><b>$author</b> says</i>:<br />$text"; } ?>
The form? You're on your own |
23yrold3yrold
Member #1,134
March 2001
![]() |
Okay, I'm going to talk in C++ here. So I'd do something like this?
And would I need seperate vectors for referencing posts by poster (so you can see a member's recent activity) and threads by forum (so when you go to OT you only see the OT threads), etc? Have I got that about right? Is the translation to PHP/MySQL relatively minor? I'll contemplate your posts too; took me a while to type that. -- |
nonnus29
Member #2,606
August 2002
![]() |
You shouldn't be working on this, you should be working on TMS!?!? Heh, well one of the first things you'll need for both items is a member table; USERID Haven't done this myself yet... Thanks for the source kanzure, I'm gonna look it over see how you do things! Edit: Yep, but the idea with SQL is that your vectors (classes too!) will tables/child tables. |
Kanzure
Member #3,669
July 2003
![]() |
23: the translation is easy, with php4/5, since there are classes. But...remember, use the database! Php scripts are only ran when a browser calls them. But the classes each would be a table, the variables would be columns. Yep. Edit: Hmm. You seem to have forgotten your unsigned char's for the names of the forums and posters |
Richard Phipps
Member #1,632
November 2001
![]() |
Unless it's almost done and he's working on the webpage? |
Kanzure
Member #3,669
July 2003
![]() |
Richardson: Doubtful.
|
Richard Phipps
Member #1,632
November 2001
![]() |
Kanzureson: I can hope. |
23yrold3yrold
Member #1,134
March 2001
![]() |
Quote: Edit: Hmm. You seem to have forgotten your unsigned char's for the names of the forums and posters.
PHP does not support unsigned integers. I did lots of work on TMS this week, and will continue to do more today. That's the "other stuff" I mentioned. -- |
Kanzure
Member #3,669
July 2003
![]() |
Quote: (Hey you sound Japanese!) Good job. Took you people long enough. Edit: Quote: Take that back. I was commenting to the C++! Php has simple variables. $name = "Sir Bob Johnson Yeighen Heighmer Smith (the one that's my name too!), Senior, the Third" Edit2: Quote: Sounds like a tekken fighter to me.
I went to a friendly japanese to english translation site, typed in a few words, and combined them. Can't remember any of them, but one of them was "hazure", and..uh..hmm.. Oh well. Supposadly, my name was a combination of words - "End of Perfection" (I was young, mind you. I was perfect, and still am |
Richard Phipps
Member #1,632
November 2001
![]() |
Sounds like a tekken fighter to me. |
Oscar Giner
Member #2,207
April 2002
![]() |
Quote: Okay, I'm going to talk in C++ here. So I'd do something like this? Problem about thinkin in c++ is that SQL is not OO. For example, in that post you said that a thread would have (among other things) a vector of posts, but that's not doable in SQL. I prefer thinking directly in tables. That's how it would look like:
MySQL doesn't support foreign keys, but I put them anyway to make things clearer. This is the basic form. You can store some derived info in some tables to make things easier/faster. For example, in my forums, I store the number of posts of a thread in the thread table. This makes simpler to count the number of posts in a forum. I also found useful storing the post id of the last post of the thread. Just don't forget to update these Quote: Sometimes I hear people talk about programs they use for adding news to their sites or something ... not sure if that's just my imagination ... The news on my web page are stored in a database. I have a small admin page where I can add news. -- |
BAF
Member #2,981
December 2002
![]() |
why not have a look at the pixelate php? i wrote all that... that could teach you (except for the forums, i just hacked those to make it look somewhat decent) |
Thomas Fjellstrom
Member #476
June 2000
![]() |
23: the only thing Id add is that a post and a thread are virtually the same thing. My forums are setup that way, so technically it can be a threaded style forum, but currently its just setup to do the allegro.cc style (I hear matthew has the same type setup, the "threads" can actually be real threads). I also have sub forums, so each forum can have children forums to make things a bit cleaner. -- |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Quote: Okay, I'm going to talk in C++ here. So I'd do something like this? I would heavily advise one thing: stay away from OOP on the web with scripted languages. The easiest way to get something done is to simply have a single PHP page represent a page as seen with a browser. It's not the most elegant of approaches, but it's super easy to work with. In general, I build pages like:
The trouble with OOP and web scripts is that ultimately you end up having every class depend on every class and you end up having to include all your files for each page view. While, this is fine for desktop applications that are compiled, it's not good for the web. You should focus on keeping things straight-forward. I find OOP most useful in PHP for utility classes. Things like general DB connecitivy, sending e-mails, etc. I do not find it very helpful for representing things like Members, Forums, etc. |
Kanzure
Member #3,669
July 2003
![]() |
Speaking of these forums, I suggest some people take the ideas used here. ML said once that he designed replies to be able to easily a new thread in itself, with a few clicks. That'd be a neat feature to add. |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Yes, the posts/threads here are all in the same table. The initial post has a parent id of 0 and all other posts have a parent id of the initial post. To implement sub-threads, they would just have to have parent ids of secondary posts. However, if you know you are not going to do a threaded board, I would have a "forum_thread" and a "forum_post" table, mostly for optimization. |
nonnus29
Member #2,606
August 2002
![]() |
So what is a session id and how does it work? |
Kanzure
Member #3,669
July 2003
![]() |
Are you talking to me? edit: (I'm serious. You kind of have to use contexts, |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Quote: So what is a session id and how does it work? The web is stateless, so there's no way to tell that a person requested a consecutive string of pages. The session id is simply a magic number that is sent back and forth between the client and server on every page view to keep track of who is who. After X time of no page loads, the magic number expires and the session is lost. If it sounds like a hack, it's because it is. The entire WWW (and Internet as a whole...) is run on a bunch of disjointed poorly planned protocols and languages that sorta work together. |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Just think, all the major internet protocols are based on Telnet! -- |
Krzysztof Kluczek
Member #4,191
January 2004
![]() |
All major protocols are based on TCP/IP. Telnet is terminal protocol and AFAIK includes some escape codes to move cursor around and do other stuff which HTTP and FTP won't understand. Matthew: Have you implemented your sessions yourself? Is this system better than PHP 4 sessions? ________ |
Matthew Leverton
Supreme Loser
January 1999
![]() |
Quote: Matthew: Have you implemented your sessions yourself? Is this system better than PHP 4 sessions? This is how the PHP sessions work, along with every other web language. I just use the native session handler. |
|
|