Jump to content
Sign in to follow this  
shashib

Display Table View with Pagination - Php - Mysql

Recommended Posts

I have 4 Column ( id (primary) , a, b ,c ,d )

--------------------------------------------------------------------------------------------------------------------------------ID     |     A     |      B       |       C ( where C = SUM  B )               |        D ( where D =  C /  A1 , Where A1 = 6 )-------------------------------------------------------------------------------|------------------------------------------------1      |     4     |      3       |                  8                         |                 22      |     6     |      2       |                                            |                 3      |     1     |      3       |                                            |                 -------------------------------------------------------------------------------|--------------------------------------------------

How i can display such table with pagination .

 

Both A , B value are Input text Field , which entry are made by user side and its stored in Database table , but C value is addition of B (TOTAL) .

 

where C = SUM B where D = C / A1 , Where A1 = 6

 

HENCE how i can get C,D as A,B coloumn get increment , and c,d will be calculation of it , hence how i can show such TABLE VIEW with Pagination .

 

note : Not tried any thing , as i am bit confuse how to start :(

Share this post


Link to post
Share on other sites

You need to learn only few things first in pagination concept.

 

1. You get page no.

2. find limit, number of results shows on each page and starting point

3. total number of records

4. then make query and display result

 

 

<?phperror_reporting('E_ALL ^ E_NOTICE');mysql_connect('localhost','root','') or die(mysql_error());mysql_select_db('new') or die(mysql_error());$page=$_REQUEST['p'];$limit=10;if($page==''){ $page=1; $start=0;}else{ $start=$limit*($page-1);}$query=mysql_query("select * from table1 limit $start, $limit") or die(mysql_error());$tot=mysql_query("select * from table1") or die(mysql_error());$total=mysql_num_rows($tot);$num_page=ceil($total/$limit);echo'<table><th>Reg.Id</th><th>Name</th><th>Category</th>';while($res=mysql_fetch_array($query)){ echo'<tr><td>'.$res['game_ID'].'</td><td>'.$res['game_Title'].'</td><td>'.$res['category_Name'].'</td></tr>';}echo'</table>';function pagination($page,$num_page){ echo'<ul style="list-style-type:none;">'; for($i=1;$i<=$num_page;$i++) { if($i==$page){ echo'<li style="float:left;padding:5px;">'.$i.'</li>';}else{ echo'<li style="float:left;padding:5px;"><a href="pagination.php?p='.$i.'">'.$i.'</a></li>';} } echo'</ul>';}if($num_page>1){ pagination($page,$num_page);}?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...