Jump to content

Recommended Posts

And here it is: http://pastebin.com/m1da4368b

 

Or at least the beginning of it.  Naturally I'll keep working on that.  However, I have a question about two things I just don't know how to do at all.  How do I keep track of, and show, the thread views?  Also, if there's anything else that looks amazingly stupid and needs fixing, please tell me.  Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/63426-writing-a-simple-forum/
Share on other sites

Oops.  Sleep deprivation made me not post the other question.  And that is...  I wish to make the same input form post the data as a new thread if no other thread is being viewed, or pass a viewed thread's ID to the script to post it as a reply.

 

if(viewing thread){

append to post/thread ID

}

else{

post as new thread

}

 

Something like that.  Which I know means I have to pass the post or thread ID to the script.  Maybe use a default value (zero or whatever) if no thread is being viewed?

 

How do I keep track of, and show, the thread views?

 

You could simply have a MySQL column holding the thread view number, and then do a query every time the page loads to update that column, and add 1 to its value.

 

 

if(viewing thread){

append to post/thread ID

}

else{

post as new thread

}

 

Use a session, cookie, or maybe GET variable to identify a thread ID.

 

if (isset($_GET['tid'])){
    /*Post to topic where*/
}else{
    /*Post new topic*/
}

  • 2 weeks later...
  • 1 month later...

Ok, I'm back on this project after benig sidetracked by something else. So here's what I'm thinking.

 

My table:

create table forum{
postid int(5) not null auto-increment, 
parentid int(5) default null, 
subject tinytext not null, 
message text not null, 
name = tinytext not null, 
post_timestamp TIMESTAMP(, 
numviews int(5) default null, 
primary key (postid)
};

 

GET on forum page takes in a parentid from a post if you've clicked on one. If no parentid, it is set to 0.

 

On main page, select statement lists all with parentid==0 as threads. Click on any of those and it just displays all posts with a parentid of that thread/post.

 

Oh, I'm not bothering with registrations, just using an image verification to block bots.

 

So:

if( get isn't set )
parentid = 0
else
parentid = whatever was in get

 

I'm going to stick the entire forum in a single file, since it's going to be so simple. I mean, all I have to do is display a list of threads, display a form, display a thread if one has been clicked (vie GET I suppose), and select whether the new post from that form creates a new thread or is appended to an already existing thread. All I need now is tips on organising the structure. Eg:

if ( GET is zero )
{
  show list of threads
  show input form
  if (input form used )
{
  create thread
}
}
else
{
show thread given by postid in GET
show input form
}

Something like that?

 

just to point out they are here to help,

you will notice you have had no "answers" to anything you have posted,

thats because you are not clearly stating what your problems are,

all you are doing is posting what you are currently doing,

they asked about the questions because they wanted to try and help, they could have just said no clear questions and gone away. but they didn't they decided to try again and ask you do you actually have a question to try and get you to state them clearer,

next time if you want help remember that being polite usually gets the best results, in fact i am sure that if you read in the forum rules it will state that you must respect other members.

 

now try and be more polite and remember that they are here to help as a favor its not your right to be helped, now if you want help be polite and post your questions clearly and the members of the forum will try to help you out.

 

also you might want to look at the link in MadTechie's sig How to ask questions the smart way http://catb.org/~esr/faqs/smart-questions.html

I'm going to stick the entire forum in a single file, since it's going to be so simple. I mean, all I have to do is display a list of threads, display a form, display a thread if one has been clicked (vie GET I suppose), and select whether the new post from that form creates a new thread or is appended to an already existing thread. All I need now is tips on organising the structure. Eg:

if ( GET is zero )
{
  show list of threads
  show input form
  if (input form used )
{
  create thread
}
}
else
{
show thread given by postid in GET
show input form
}

Something like that?

So how about I repeat the question regarding design, and hope for some constructive, intelligence input.

Okay, it seam to me, that you don't have a specific question, just a but a programming design question, which is unclear..

 

can you please re-phrase the question (maybe bullet point it).. or just continue to rant and your probably be left alone  ::)

 

 

 

How to ask questions the smart way

I'm going to stick the entire forum in a single file, since it's going to be so simple. I mean, all I have to do is display a list of threads, display a form, display a thread if one has been clicked (via GET I suppose), and select whether the new post from that form creates a new thread or is appended to an already existing thread. All I need now is tips on organising the structure. Eg:

if ( GET is zero )
{
  show list of threads
  show input form
  if (input form used )
{
  create thread
}
}
else
{
show thread given by postid in GET
show input form
}

Something like that?

Given the requirements mentioned, is that how you would design such a thing, if trying to gather it all into one file rather than splitting it into several?

i guess like this, yet your still unclear!

 

<?php
switch($_GET['page'])
{
default:
case "1":
//include or echo page data for default or main (1) page
break;
case "2":
//include or echo page data for page 2
break;
case "3":
//include or echo page data for page 2
break;
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.