HumzaKhan Posted June 20, 2012 Share Posted June 20, 2012 <Videos> <Video> <Title>1</Title> <Desc>check..</Desc> </Video> <Video> <Title>2</Title> <Desc>check again</Desc> </Video> <Video> <Title>3</Title> <Desc>check again & again</Desc> </Video> </Videos> Well, i was trying to display data from an XML File in such a way so that only Data of 5 'Video' tags appear on a page and for the rest, a row consisting of page numbers should appear. It's similar to the number of replies that display on a page in a SMF Forum. For the rest, we can see a row consisting of Numbers. I succeeded in making the Number's Row but can't split it into pages. So can anyone give me a short tutorial? [/code] Quote Link to comment https://forums.phpfreaks.com/topic/264512-a-little-help/ Share on other sites More sharing options...
litebearer Posted June 20, 2012 Share Posted June 20, 2012 keyword: pagination? Quote Link to comment https://forums.phpfreaks.com/topic/264512-a-little-help/#findComment-1355573 Share on other sites More sharing options...
freeublue Posted June 20, 2012 Share Posted June 20, 2012 Pagnation means splitting your data up into managable chunks. This can be handled in a number of ways. 1. array Chunk your array using array_chunk. 2. select x elements from your array in an iterated fashion eg: 5, then add or subtract 5, based on the direction of viewing..ie:- next page or previous page. 3. this is my database selection for my pagnation. <?php include "config.php"; echo "<div id='fp'>"; $who = 'begin'; if (isset($_POST['sta']) ) { $ne = $_POST['sta']; $start = ($ne * 10) -2; $who = $_POST[who]; } else if (! isset($_GET['start']) ) { $start = '0'; $nstart = '0'; $who = 'begin'; } else { $start = $_GET['start'] + 10; $nstart = $start - 20; } $qe = mysql_query("SELECT * FROM casstory WHERE catagor = '$who'"); while ($ro = mysql_fetch_object($qe) ) { $af[] ="$ro->id"; } $q = mysql_query("SELECT * FROM casstory WHERE catagor = '$who' ORDER BY title ASC LIMIT $start, 10"); while ($row = mysql_fetch_object($q) ) { $about = stripslashes($row->title); echo "</b><a href='st.php?id=$row->id'>$about</a><br />"; } $armax = count($af); $coun = ceil($armax / 10); echo "<br />There are $coun pages<br />"; echo "<form action='selectstory.php' method='post'><input type='text' name='sta' size='3' /><input type='hidden' name='who' value='$who' /><input type='submit' value='Go' /></form><br />"; if ($start == 0) { echo "<a href='selectstory.php?start=$start&&who=$who'>NEXT PAGE</a><br />"; } else if ($start < $armax ) { echo "<a href='selectstory.php?start=$start&&who=$who'>NEXT PAGE</a><br />"; echo "<a href='selectstory.php?start=$nstart&&who=$who'>PREVIOUS PAGE</a><br />"; } else { echo "<a href='selectstory.php?start=$nstart&&who=$who'>PREVIOUS PAGE</a><br />"; } $su = count($af); ?> Quote Link to comment https://forums.phpfreaks.com/topic/264512-a-little-help/#findComment-1355586 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.