quickstopman Posted May 14, 2007 Share Posted May 14, 2007 her guys im currently trying to make a system of post and i don't want all the posts on one page i have some php that limits how many articles are shown but it doesn't make the pages needed to view the other articles here is the code <?php include 'header.php'; //connect to and select db $conn = mysql_connect('localhost','user','password') or die(mysql_error()); $db = mysql_select_db('pokebash_users',$conn) or die(mysql_error()); //get a list of the info from the table to make the linkies $page = (isset($_GET['page']))?$_GET['page']:1; // page number $X = ($page - 1); $Y = (5 * $page); $sql = "select * from news ORDER BY id desc Limit $X,$Y "; $result = mysql_query($sql, $conn) or die(mysql_error()); // for each row fetched from the results... echo "<table align='center' width='100%'>"; while ($list = mysql_fetch_array($result)) { //make the custom linkie echo " <tr height='70px' width='500px'> <td><a href='post.php?id={$list['id']}'>{$list['topic']}</a></td><td>By: {$list['user']}</td><td>At: {$list['time']} </td> </tr> "; } // end while echo "</table>"; if ( // if the user clicked on a linkie and therefore an id exists (the is_numeric is a basic security precaution) ... if (is_numeric($_GET['id'])) { // for easier var syntax handling $id = $_GET['id']; $sql = "select topic from news where id = '$id'"; $result = mysql_query($sql, $conn) or die(mysql_error()); $userfound = mysql_num_rows($result); if ($userfound) { $user = mysql_fetch_array($result); } // end if found } // end if there was a linkie clicked ?> Quote Link to comment https://forums.phpfreaks.com/topic/51334-page-system/ Share on other sites More sharing options...
quickstopman Posted May 14, 2007 Author Share Posted May 14, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/51334-page-system/#findComment-252865 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.