0

I have a datagrid which is successfully loading a database in my .PHP page that loads Title, Location, and Date. I have struck up, struggling to allow only 8 records at a time with a pagination. Also a link has to be created for 1st column where it links the Title list to a new page. I want the new page to load the Description of the selected Title (i.e record) from the previous page. I've an ID column in MySQL with auto increment. Help me to sort it out!!!

3
Contributors
5
Replies
8
Views
4 Years
Discussion Span
Last Post by diafol
0

@Karry.Stewart

I have struck up, struggling to allow only 8 records at a time with a pagination. Also a link has to be created for 1st column where it links the Title list to a new page. I want the new page to load the Description of the selected Title (i.e record) from the previous page. I've an ID column in MySQL with auto increment. Help me to sort it out!!!

Can you post your table and query.

0

@LastMitch

There are a series of pages I've created as page3.1 page3.2 page3.3 page3.4/ These each page has a filter applied to search the record from DB w.r.t weekly, Monthy and Overall etc. This code is for page3.1 which searches the DB for records posted on current date. Correct me if I'm going wrong by creating pages like this instead of just one page3.

<table border="1" cellpadding="0" cellspacing="0" width="500" height="300">
    <tr>
    <td width="0"> <b> Title   </b></td>  
    <td width="0"> <b> Location</b></td>
    <td width="0"> <b> Date    </b></td>
    </tr>

<?php 
$host="localhost";
$user="root";
$pass="";

$db="bptdatabase";
$format="%Y-%m-%d ";
$date1=strftime($format);


mysql_connect($host,$user,$pass) or die('Error 101 :please try after some time ');

mysql_select_db($db)or die('Error 102: please try after some time ');

$result = mysql_query("SELECT * FROM bp where Date='$date1'");

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><a href='page4.php'>" . $row['Title'] . "</td>";
  echo "<td>" . $row['Location'] . "</td>";
  echo "<td>" . $row['Date'] . "</td>";

  echo "</tr>";
  }
?>
</table>
0

@Karry.Stewart

Correct me if I'm going wrong by creating pages like this instead of just one page3.

What are you trying to do? The code you provided doesnt have any errors and looks right.

I'm not sure why you have pages like this:

page3.1
page3.2
page3.3
page3.4

If you just want to fetch data from the previous page, all you need to do is to fetch that data from the database and echo it to the next page.

Edited by LastMitch: grammer

0

@LastMitch

I'm not sure why you have pages like this:

Let me clearly say you I've a set of six pages and starting from screen I is an index page and screen II I've created 4 Buttons which acts a search today,search weekly,search monthly etc. I've created seperate pages for each of the above 4 and applied a filter in these seperate pages like for page3.1 is for 'search Todays'

$result = mysql_query("SELECT * FROM bp where Date='$date1'");

What I'm struggling with is creating only one webpage acting for all the 4 Buttons and only information keeps changing that comes from MySQL. I know that I've to apply all the filters code in screen II itself and link each button to the next page, How do I do this?

0

Pagination has been covered to death on this forum. Try searching for 'pagination' first. You'll need the basic variables:

1) $num_records_per_page (8 in your case?)
2) $total_records (from the DB)
3) $num_pages (calculated as ceil($total_records/$num_records_per_page))
4) $current_page (default setting = 1, but then taken from the $_GET['page'] variable if it's set and within range)

You use the LIMIT clause in the mysql to filter which records to display.

Your 'page links' can then be built up from a loop (page numbers in range) with output such as:

$link_array[] = ($i == $current_page) ? $i : "<a href='?page=$i'>$i</a>";

Then stringify it:

$link_string = implode(" | ", $link_array);

Anyway, just a bit of info.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.