Here's the two questions I have to ask.
1) How can I limit my thread viewing to x posts per page.
2) Should I use use something in my _GET to prevent SQL injection?
<?php
/////////////////////////////////////////////////////////////////////////////////////
//// Get this thread ////////////////////////////////////////////////////////////////
$t = $_GET['t'];
/////////////////////////////////////////////////////////////////////////////////////
//// Get the posts in the thread ////////////////////////////////////////////////////
$post = mysql_query("SELECT * FROM posts WHERE topic=$t ORDER BY id ASC");
/////////////////////////////////////////////////////////////////////////////////////
//// If there is query dont work do not show ////////////////////////////////////////
if (!$post) {
die('Invalid query: ' . mysql_error());
}
/////////////////////////////////////////////////////////////////////////////////////
//// Update the views when seen /////////////////////////////////////////////////////
mysql_query("UPDATE topics SET views=views+1 WHERE id=$t");
/////////////////////////////////////////////////////////////////////////////////////
//// Post list top //////////////////////////////////////////////////////////////////
include("././templates/post_list_top.php");
/////////////////////////////////////////////////////////////////////////////////////
//// Show the posts /////////////////////////////////////////////////////////////////
while ($row = mysql_fetch_array($post)) {
$i = mysql_query("SELECT * FROM members WHERE name='" .$row['author']. "'");
$info = mysql_fetch_array($i);
$t = mysql_query("SELECT * FROM topics WHERE id='" .$t. "'");
$topic = mysql_fetch_array($t);
$row['author'] = "<a href='./index.php?page=profile&m=" .$row['author']. "'>$row[author]</a>";
include("././templates/post_list.php");
}
/////////////////////////////////////////////////////////////////////////////////////
//// Bottom of the page ////////////////////////////////////////////////////////////
include("././templates/post_list_bottom.php");
?>