$php_mysql$ Posted August 6, 2011 Share Posted August 6, 2011 need ta get pagination done my code where i was the pagination echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\" width=\"100%\">"; if(!count($Post)) { print 'no records'; } else { echo "<tr class=\"rowhead\">\n"; echo " <th>Image</th>\n"; echo " <th>Ad Title</th>\n"; echo " <th>Type</th>\n"; echo " <th>State </th>\n"; echo " <th>City/Town</th>\n"; echo " <th>Posted</th>\n"; echo "</tr>\n"; $rowClass = ''; foreach($Post as $p) { $rowClass = ($rowClass!='row1') ? 'row1' : 'row2'; $link = "<a href=\"details.php?name=$Name&ID=".$p['id']."\">{$p['title']}</a>"; $state = str_replace('_', ' ', $p['state']); if(empty($p['image'])) { $image = 'no image'; } else { $image = "<img src=\"{$p['image']}\" width=\"50px\" height=\"50\" alt=\"{$p['image']}\"/>"; } echo "<tr class=\"{$rowClass}\">\n"; echo " <td>{$image}</td>"; echo " <td>{$link}</td>"; echo " <td>{$p['type']}</td>\n"; echo " <td>{$state}</td>\n"; echo " <td>{$p['location']}</td>\n"; echo " <td>{$p['adtime']}</td>\n"; echo "</tr>\n"; } echo "</table>"; } and my sql query function getPosts($Name) { $posts = array(); $sql = "SELECT * FROM `tbl` AS p WHERE p.category = '".$Name."' ORDER BY p.time DESC"; $rs = executeSql($sql); while($row = mysql_fetch_array($rs)) { $posts[] = $row; } return $posts; } Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/ Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Hi, Post the full code for that page where you are applying the pagination, I can help you get a kick start. Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253473 Share on other sites More sharing options...
voip03 Posted August 6, 2011 Share Posted August 6, 2011 Let me know <? // GET - page : Check if page veriables exist, ensure it is valid and numeric. if(!$_GET['page'] ) { $validpage = 1; } else { if(is_numeric($_GET['page'])== TRUE ) { $validpage = $_GET['page']; } else { $validpage = 1; } } ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor='#F8F8F8' width="2%"></td> <td bgcolor='#F8F8F8'> <table width="100%" border="0" cellspacing="0" cellpadding="1" > <tr> <td bgcolor='#F8F8F8' colspan="1 > <div align="left"><strong> <? $search_sql = "SELECT * FROM tablename WHERE fieldname LIKE '%".$search_value."%' OR fieldName LIKE '%".$search_value."%' ORDER BY fieldname ASC;" ; $search_res = mysql_query($search_sql); if(!$search_res) { die(" Could not query the database categories : <br/>". mysql_error() ); } $search_num = mysql_num_rows($search_res); //To implement paging, determine the number of pages and the number of the result ( 5 ) $pagesize = 5;// Page size $numpages = ceil($search_num/$pagesize); $limit = ($validpage - 1)*5; ?> </strong></div></td> <td bgcolor='#F8F8F8' ><div align="right"><strong> Go to page <? for($i = 1; $i<= $numpages; $i++) { echo "<a href='search.php?s=".$search_value."&page=".$i."'>".$i."</a>"; } ?> </strong></div> </div></td> </tr> <? // No record found display the table only one heading INFORMATION if( $search_num == 0 ) { echo "<tr><td colspan='6' bgcolor='#D6D6D6' height='30'align='center'><strong>Information </strong></td></tr>"; echo "<tr><td colspan='6' bgcolor='#F8F8F8' height='70' align='center'><font size='2'><strong>No suitable matches were found.</strong></font></ul></td>";} else { ?> <tr> <td></td> </tr> <tr> <td colspan="6" bgcolor="#EFEFEF" > </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253487 Share on other sites More sharing options...
AyKay47 Posted August 6, 2011 Share Posted August 6, 2011 mark topic as solved....oops I pulled a Sensei.. Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253491 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 mark topic as solved....oops I pulled a Sensei.. People private message me constantly for help, so what you see as solved is not the same for me. I know your referring to this... http://www.phpfreaks.com/forums/index.php?topic=340743.0 Ask the member himself. I love you AyKay7 <3 Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253493 Share on other sites More sharing options...
AyKay47 Posted August 6, 2011 Share Posted August 6, 2011 dude chill i'm just messing with you... no homo.... p.s you are kinder than I am, I pointed php_mysql to a plethora of pagination tuts once..wants people to do the work for him/her...no thanks and its AyKay47 not AyKay7... I get PM's all the time...I ignore them... Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253494 Share on other sites More sharing options...
phpSensei Posted August 6, 2011 Share Posted August 6, 2011 Same here, I am teasing you... I really am just kidding.. Quote Link to comment https://forums.phpfreaks.com/topic/244072-i-need-you-phpsensei-help-solve-my-issues-with-php/#findComment-1253496 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.