Jump to content

A little help


HumzaKhan

Recommended Posts

<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]

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.