Reply LinkBack Thread Tools Search this Thread
Old 09-04-2007, 21:34   #1 (permalink)
raptrex
Registered User
 
Join Date: Oct 2006
Posts: 13
displaying more than one post with its comments

ive seen many tutorials that would display a post with its comments
but havent seen a tutorial that would display more than one post, and display all their comments

how would i do this?
  Reply With Quote
Old 09-04-2007, 21:55   #2 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
In what CMS?
  Reply With Quote
Old 10-04-2007, 11:23   #3 (permalink)
raptrex
Registered User
 
Join Date: Oct 2006
Posts: 13
in php, im making my own script
  Reply With Quote
Old 10-04-2007, 15:49   #4 (permalink)
Cborrow
I like code.
 
Join Date: Dec 2004
Location: Chesapeake, VA
Posts: 229
Send a message via AIM to Cborrow
You can try something like this

Code:
<?php $dbh = mysql_connect("host", "user", "pass") or die("Could not connect to MySQL Server"); mysql_select_db("db"); $r = mysql_query("SELECT id,title,content FROM posts ORDER BY id DESC"); while($o = mysql_fetch_array($r)) { $id = $o['id']; //Display your post $r2 = mysql_query("SELECT title,comment FROM comments WHERE post_id = '$id'"); while($o2 = mysql_fetch_array($r2)) { //Display it's comments } } ?>

Last edited by Cborrow : 11-04-2007 at 21:32.
  Reply With Quote
Old 11-04-2007, 18:36   #5 (permalink)
raptrex
Registered User
 
Join Date: Oct 2006
Posts: 13
thx cborrow very much, it works like a charm
except you need to change $r to $r2 here
Code:
while($o2 = mysql_fetch_array($r)) { //Display it's comments
cuz its comming from a different row
but other than that, thx
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8