473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how do we make threads like they do in IPB

realin
254 100+
hey guys,

Well i was just thinking that how to make threads like stufff at my own. Suppose i am posting here this question, now a new html will be generated and later on the answers will be concatenated..

I mean how do it do that ?

the approach that i used was like this ::

made two tables
1) Questions
2) Answers

one stores teh questions asked and are trailed by the answers given..
Now i used to display using the query string like http://domain.com/action=view&post=9

but is it a right appraoch, cause lotsa forums rather i can say every forum uses html pages to display and the page has a unique number, i am sure these html pages are generated dynamically from one page..

but how to go along with it ..

i hope i made everything clear..
thanks in advance :)
Sep 20 '07 #1
6 3002
pbmods
5,821 Expert 4TB
Heya, Realin.

Likely, the unique ID represents the ID of a record in a database.

For example, if you were to have a URL such as:
Expand|Select|Wrap|Line Numbers
  1. http://yoursite.tld/path/to/quiz.php?question=9
  2.  
Then you'll probably find something like this in quiz.php:
Expand|Select|Wrap|Line Numbers
  1. if( ! empty($_GET['question']) )
  2. {
  3.     $_question = (int) $_GET['question'];
  4. }
  5.  
  6. if( empty($_question) or $_question < 1 )
  7. {
  8.     echo 'Invalid question.';
  9.     exit;
  10. }
  11.  
  12. $_res = mysql_query("
  13. SELECT
  14.         *
  15.     FROM
  16.         `questions`
  17.     WHERE
  18.         `questionid` = '{$_question}'
  19.     LIMIT 1");
  20. .
  21. .
  22. .
  23.  
Sep 20 '07 #2
realin
254 100+
Heya, Realin.

Likely, the unique ID represents the ID of a record in a database.

For example, if you were to have a URL such as:
Expand|Select|Wrap|Line Numbers
  1. http://yoursite.tld/path/to/quiz.php?question=9
  2.  
Then you'll probably find something like this in quiz.php:
Expand|Select|Wrap|Line Numbers
  1. if( ! empty($_GET['question']) )
  2. {
  3.     $_question = (int) $_GET['question'];
  4. }
  5.  
  6. if( empty($_question) or $_question < 1 )
  7. {
  8.     echo 'Invalid question.';
  9.     exit;
  10. }
  11.  
  12. $_res = mysql_query("
  13. SELECT
  14.         *
  15.     FROM
  16.         `questions`
  17.     WHERE
  18.         `questionid` = '{$_question}'
  19.     LIMIT 1");
  20. .
  21. .
  22. .
  23.  

hey thanks for the reply..
i have already implemented this logic but i am kinda not satisfied with it.. though i think its not the proper technique.. cause in all the boards what i saw is pages are like http://domain.com/index623612.html unlike the one i am making as http://domain.com/action=view&p=9

i hope now i make this think clear
Sep 21 '07 #3
pbmods
5,821 Expert 4TB
Heya, Realin.

Many sites make use of URL rewriting such that it appears that each record gets its own page, even though it is not the case.

For example, you might type this into your address bar:
http://www.thescripts.com/forum/thread711214.html

But it actually gets rewritten server-side to:
http://www.thescripts.com/forum/showthread.php?t=711214
Sep 21 '07 #4
realin
254 100+
hi sorry for the late reply, actually i am on travel.. i just wanted to know that URL rewriting can only be done with apache, after editing httpd.conf ? in some tutorials i read i gotta load the rewrite_module and add it.. but when i install the "phpBB" on the same machine the same kind of url(mentioned above) is shown.. i mean how is it possible..
i have used http://www.thescripts.com/forum/thread711214.html to reach this thread meaning the number 711214 does have some significanse and is stored somewhere in the database.. that is why it landed me to a correct thread..

while reading tutorials i realized that url rewriting helps search engine friendlu urls and also hides the under lying web techonolgy used, which apparently is true.. but still i am unable to achieve it..
can you clear my doubts a bit.. thanks :)
Sep 22 '07 #5
bergy
89
I normally use .htaccess files to rewrite URLs. You don't have to modify your httpd.conf file and it can be done per directory in case you have multiple sites on your server.

The trick is to make sure that mod_rewrite is enabled in apache and also there is another config option I ran into (can't remember exactly what it's called) that will try to guess which file you're trying to get if you typed something wrong... so say you try to goto domain.com/pictures and there is no pictures directory but there is a pictures.html apache will return that .html file. So, in short, make sure that option is turned off in your config - sorry I can't remember.

Anyway, here is a sample of one of my .htaccess files:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?site_action=$1 [L]
  4.  
The above rule is placed in .htaccess in the main directory of my website. If someone goes to mysite.com/home apache pulls up mysite.com/index.php?site_action=home without changing the address bar. One thing to remember, if you're using relative links in your images like:
Expand|Select|Wrap|Line Numbers
  1. <img src="images/image.jpg">
Your images won't display because your browser thinks that you are in a subdirectory (home in my example above) so it looks for "mysite.com/home/images/image.jpg". To fix this, put a leading slash in front of the image:
Expand|Select|Wrap|Line Numbers
  1. <img src="/images/image.jpg">
Remember this for any type of link/file you're referencing, a javascript, style sheet, flash movie, etc. Always have that leading slash so the server knows to start at the root of the web server.

Also, ilovejackdaniels.com has a great mod_rewrite cheatsheet. Check that out for a quick reference -- http://www.ilovejackdaniels.com/chea...e-cheat-sheet/

Thescripts.com rewrite script probably looks something like this for their forum redirects:
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^thread([0-9-]+).html?$ showthread.php?p=$1 [L]
  4.  
Sep 22 '07 #6
realin
254 100+
I normally use .htaccess files to rewrite URLs. You don't have to modify your httpd.conf file and it can be done per directory in case you have multiple sites on your server.

The trick is to make sure that mod_rewrite is enabled in apache and also there is another config option I ran into (can't remember exactly what it's called) that will try to guess which file you're trying to get if you typed something wrong... so say you try to goto domain.com/pictures and there is no pictures directory but there is a pictures.html apache will return that .html file. So, in short, make sure that option is turned off in your config - sorry I can't remember.

Anyway, here is a sample of one of my .htaccess files:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?site_action=$1 [L]
  4.  
The above rule is placed in .htaccess in the main directory of my website. If someone goes to mysite.com/home apache pulls up mysite.com/index.php?site_action=home without changing the address bar. One thing to remember, if you're using relative links in your images like:
Expand|Select|Wrap|Line Numbers
  1. <img src="images/image.jpg">
Your images won't display because your browser thinks that you are in a subdirectory (home in my example above) so it looks for "mysite.com/home/images/image.jpg". To fix this, put a leading slash in front of the image:
Expand|Select|Wrap|Line Numbers
  1. <img src="/images/image.jpg">
Remember this for any type of link/file you're referencing, a javascript, style sheet, flash movie, etc. Always have that leading slash so the server knows to start at the root of the web server.

Also, ilovejackdaniels.com has a great mod_rewrite cheatsheet. Check that out for a quick reference -- http://www.ilovejackdaniels.com/chea...e-cheat-sheet/

Thescripts.com rewrite script probably looks something like this for their forum redirects:
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^thread([0-9-]+).html?$ showthread.php?p=$1 [L]
  4.  

hey man,

thanks a lot, would check that soon.. its really informative really really thanks a lot, have kept it for future reference too :)

thanks once again
Sep 23 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
11
by: mareal | last post by:
I am trying to write a basic load balancer (in our web service) solution. The purpose of this load balancer is to keep an array updated with server status. We have several servers that can be...
35
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? ...
9
by: bonk | last post by:
Does anyone have a simple example on how to prohibit that any thread other than the current thread modifies a certain object (a collection) while we are in a certain section of the code? In other...
4
by: gsimmons | last post by:
I've been researching multi-threaded WinForms apps and thread synchronization stuff for a couple days since I'm working on refactoring a multi-threaded GUI app at work and want to be sure it's...
10
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005 and .net 2.0. I started 2 threadpool threads. How do I know when they're done with their tasks? Thanks. ThreadPool.QueueUserWorkItem(new...
3
by: JohnM | last post by:
Hi there, Are there any specific rules or best-practices I should be aware regarding events and the threads they're fired on. Object 1 can be created on thread 1 for instance and an event then...
18
by: Jon Slaughter | last post by:
"Instead of just waiting for its time slice to expire, a thread can block each time it initiates a time-consuming activity in another thread until the activity finishes. This is better than...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.