Maybe this is where I'm confused...
From what I've read you need to query the db to get the values to create the link url in (e.g. main.php) and then you need to query the db again in the next page (e.g. results.php) to get the results from the link. Is that correct or am I way off.
Here is the code I am using to create the link from:
$sql2 = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
FROM (( " . FORUMS_TABLE . " f
LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
ORDER BY f.cat_id, f.forum_order";
$result2 = mysql_query($sql2, $connection) or die(mysql_error());
while ($forums_rows = mysql_fetch_array($result2)) {
$forum_id = $forums_rows['forum_id'];
$forum_name = $forums_rows['forum_name'];
$forum_desc = $forums_rows['forum_desc'];
$forum_posts = $forums_rows['forum_posts'];
$forum_topics = $forums_rows['forum_topics'];
$forum_last_post_id = $forums_rows['forum_last_post_id'];
$count = 1;
$content .= "<a href=\"main.php?Forums=viewform?Forum=$forum_id\">$forum_name</a>";
$count = $count + 1;
}
I should have a query on the page that returns the link right?
I have tried but I probably have it totally wrong. This is what I have for that...
$Fourm = $_GET['forum_id'];
db_connect();
$sql2 = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
ORDER BY t.topic_last_post_id DESC
LIMIT $forums_topics_per_page";
$result2 = mysql_query($sql2, $connection) or die(mysql_error());
while ($topic_rows = mysql_fetch_array($result2)) {
$topic_id = $topic_rows['topic_id'];
$topic_title = $topic_rows['topic_title'];
$topic_poster = $topic_rows['topic_poster'];
$topic_views = $topic_rows['topic_views'];
$topic_last_post_id = $topic_rows['topic_last_post_id'];
$topic_replies = $topic_rows['topic_replies'];
// echo "Output html";
Like I said, it's probably wrong but when I call the link with the variable in it I get my template returned with a blank content area. If I just go directly to the results page there are no results of course but the page does display. So anyways, it may take me a while to get my head wrapped around this stuff for the first time but I'm trying.