Page 1 of 1

displaying sql data on different pages

Posted: Wed Mar 14, 2012 9:02 am
by Smithers
Hey there,
I am not quite sure how to explain my plan but I just give it a try.
Basically I want to display results from an sql query into a search engine kind of style. Lets say, I have 15 results in my query, currently these results are displayed in a simple table. However what I would like to have is displaying 5 results on the page and below the page I want to have numbers (1-4) which allow me to view results 5-8 in page 2 and results 9-14 in page 3.

Below is the code I've been written so far. Hopefully what I am asking does make any....
Many Thanks

<?php
$id = ($_SESSION['id']);	
$sql = "SELECT * FROM users,posts WHERE users.id = posts.poster_id";		
$result = mysql_query($sql);
if(!$result)
{
echo 'No posts.';
}
else
{
echo '<table border="1">
 <tr>
<th>Username</th>
<th>Date</th>
<th>topic</th>
<th>Website</th>
</tr>';	
while($row = mysql_fetch_assoc($result))
{				
echo '<tr>';
echo '<td>';
echo '<h3><a href="edit_event.php?id=' . $row['id'] . '">' . $row['username'] . '</a><br /><h3>';
echo '</td>';
echo '<td>';
echo date('d.m.y', strtotime($row['event_date']));
echo '</td>';
echo '<td>';
echo $row['topic'] ;
echo '</td>';
echo '<td>';
echo $row['website'] ;
echo '</td>';
echo '</tr>				
';
}
}
}
?>
</table>

Re: displaying sql data on different pages

Posted: Wed Mar 14, 2012 5:12 pm
by jacek

Re: displaying sql data on different pages

Posted: Wed Mar 14, 2012 6:20 pm
by Smithers
Thanks a lot,
I start loving you ;-)

Re: displaying sql data on different pages

Posted: Fri Mar 16, 2012 9:58 pm
by jacek
Smithers wrote:Thanks a lot,
I start loving you ;-)
Good... I guess ;)