displaying sql data on different pages

Ask about a PHP problem here.
Post Reply
Smithers
Posts: 8
Joined: Mon Feb 06, 2012 3:09 pm

displaying sql data on different pages

Post 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>
Last edited by jacek on Wed Mar 14, 2012 5:10 pm, edited 1 time in total.
Reason: code tags...
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: displaying sql data on different pages

Post by jacek »

Image
Smithers
Posts: 8
Joined: Mon Feb 06, 2012 3:09 pm

Re: displaying sql data on different pages

Post by Smithers »

Thanks a lot,
I start loving you ;-)
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: displaying sql data on different pages

Post by jacek »

Smithers wrote:Thanks a lot,
I start loving you ;-)
Good... I guess ;)
Image
Post Reply