Author Topic: Pagination no database  (Read 427 times)

jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Hi

im wondering how i could implement Pagination to my media
here is my function...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  function get_media($media_cat$display_recent$purifier$media_id) {
  
	
if (!empty(
$media_id)) {
  
	
	
if (
$media_id == $media_cat) {
  
	
	
	
$display_recent null;
  
	
	
}
  
	
}
  
	
$files = array();
  
	
$files glob(MEDIA_BASEDIR.$media_cat.'/*.txt');
  
	
usort($files, function($x$y) {
 
	
	
return 
$x $y;
 
	
	
});
 
	
$recent_content array_slice($files0$display_recent);
 
	
foreach (
$recent_content as $media) {
 
	
	
$line file($media);
 
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
$date_time basename($media);
 
	
	
$date_time basename($media'.txt');
 
	
	
$content file_get_contents($media);
 
	
	
$content str_replace($media_title,'',$content);
 
	
	
thememediatop($media_title$media_cat$media_id);
 
	
	
print_r ($purifier->purify($content));
 
	
	
thememediabottom($date_time);
 
	
}
 }



i will probably make a new function for the media page itself for the pagination, this function can be placed on any page by telling it what directory to use and how many to display useing...

1
 get_media('Announcements'1$purifier$media_id);


any help would be great, thanks.

PHP Help Forum

Pagination no database
« on: March 20, 2017, 04:37:49 pm »



PHP Help Forum

Re: Pagination no database
« Reply #1 on: March 21, 2017, 06:56:55 pm »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
I need help to paginate my media, this is my first attempt at one...

I have tried to implement this pagination from this site:
http://www.devnetwork.net/viewtopic.php?f=1&t=128417 but i cant get it to work.. i cant see where i have gone wrong...

here is what iv managed to do with it so far.. but its not working

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  function media_index($purifier$media_id) {
  
	
$files = array();
  
	
$files glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
  
	
$records_per_page 6;
  
	
$total_records count($files);
  
	
$total_pages ceil($total_records $records_per_page);
  
  
	
if isset((int)
$_GET['p']) {
 
	
	
$current_page = (int)$_GET['p'];
 
	
}
 
	
if(
$current_page<|| $current_page>$total_pages)
 
	
{
 
	
	
$current_page 1;
 
	
}
 
	

 
	
usort($files, function($x$y) {
 
	
	
return 
$x $y;
 
	
	
});
 
	
	

 
	
$media_content array_splice($files, ($current_page-1)*$records_per_page$records_per_page);
 
 
	
foreach (
$media_content as $media) {
 
	
	
for (
$col=0$col<$records_per_page$col++) {
 
	
	
	

 
	
	
	
$line file($media);
 
	
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
	
$date_time basename($media);
 
	
	
	
$date_time basename($media'.txt');
 
	
	
	
$content file_get_contents($media);
 
	
	
	
$content str_replace($media_title,'',$content);
 
	
	
	

 
	
	
	
thememediatop($media_title$media_cat$media_id);
 
	
	
	
print_r ($purifier->purify($content));
 
	
	
	
thememediabottom($date_time);
 
	
	
}
 
	
}
 
	

 
	
$first "First";
 
	
$prev  "Prev";
 
	
$next  "Next";
 
	
$last  "Last";
 
	
if(
$current_page>1) {
 
	
	
$prevPage $current_page 1;
 
	
	
$first "<a href='./?page=Media&id={$media_id}&p=1'>{$first}</a>\n";
 
	
	
$prev  "<a href='./?page=Media&id={$media_id}&p={$prevPage}'>{$prev}</a>\n";
 
	
}
 
	
if(
$current_page<$total_pages) {
 
	
	
$nextPage $current_page 1;
 
	
	
$next "<a href='./?page=Media&id={$media_id}&p={$nextPage}'>{$next}</a>\n";
 
	
	
$last "<a href='./?page=Media&id={$media_id}&p={$total_pages}'>{$last}</a>\n";
 
	
}
 
	
 
 
	
print (
"{$first} | {$prev} | {$next} | {$last}");
 }



i have tried to update the code from that site best i can, im still learning.

thanks

PHP Help Forum

Re: Pagination no database
« Reply #2 on: March 21, 2017, 08:16:20 pm »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Sorry i noticed i did not close the isset function...
i have tried to get this working and still getting no output and no error..

also nothing else runs after wherever the falt is in this function..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  function media_index($purifier, $media_id) {
   $files = array();
   $files = glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
   $records_per_page = 6;
   $total_records = count($files);
   $total_pages = ceil($total_records / $records_per_page);
  
   if (isset($_GET['p'])) {
  $current_page = (int)$_GET['p'];
  }
  if ($current_page<1 || $current_page>$total_pages) {
  $current_page = 1;
  }
 
  usort($files, function($x, $y) {
  return $x < $y;
  });
 
  $media_content = array_splice($files, ($current_page-1)*$records_per_page, $records_per_page);
 
  for ($col=0; $col>$records_per_page; $col++) {
  foreach ($media_content as $media) {
 
  $line = file($media);
  $media_title = ($purifier->purify($line[0]));
  $date_time = basename($media);
  $date_time = basename($media, '.txt');
  $content = file_get_contents($media);
  $content = str_replace($media_title,'',$content);
 
  thememediatop($media_title, $media_cat, $media_id);
  print_r ($purifier->purify($content));
  thememediabottom($date_time);
  }
  }

thanks
« Last Edit: March 22, 2017, 06:56:35 pm by jimbo »

PHP Help Forum

Re: Pagination no database
« Reply #3 on: March 22, 2017, 06:51:18 pm »


Kevin Rubio

  • Professional PHP Helper
  • Senior Member
  • *
  • Posts: 1814
  • Karma: 108
  • Programmer Available for hire
    • View Profile
    • Galaxy Internet
See what this does for you. You will have to modify it for your purpose.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  <?php
  
/**
   * @author Kevin Rubio
   * Website: http://galaxyinternet.us/php-pagination-array-chunk-pagination/
   */
  
  //----------------------------------------------------------------------------
  // Generate Sample Data
  //----------------------------------------------------------------------------
 
 
foreach (range(140) as $value)
     {
     
$data[] = array(
         
'Product' => 'Product ' $value,
         
'Price' => rand(10100),
         
'Quantity' => rand(125)
     );
     }
 
 
//----------------------------------------------------------------------------
 // Number Of Chunks
 //----------------------------------------------------------------------------
 
 
$number_of_chunks 4;
 
 
//----------------------------------------------------------------------------
 // Break Array Into Chunks
 //----------------------------------------------------------------------------
 
 
$data array_chunk($data$number_of_chunks);
 
 
//----------------------------------------------------------------------------
 // Get Page Count
 //----------------------------------------------------------------------------
 
 
$pagecount count($data);
 
 
//----------------------------------------------------------------------------
 // Make sure page is set and is numeric
 //----------------------------------------------------------------------------
 
 
if (isset($_GET['p']) && (is_numeric($_GET['p'])))
     {
     if (
$_GET['p'] > $pagecount)
         {
         die(
'<span style="color:#FF0000">Error: Page Does Not Exist</span>');
         }
     
$i $_GET['p'] - 1;
     }
 else
     {
     
$i 0;
     }
 
 
//----------------------------------------------------------------------------
 // Display array_chunk Data
 //----------------------------------------------------------------------------
 
 
echo '<pre>';
 
print_r($data[$i]);
 echo 
'</pre>';
 
 
//----------------------------------------------------------------------------
 // Display array_chunk Pagination
 //----------------------------------------------------------------------------
 
 
for ($i 1$i <= $pagecount$i++)
     {
     echo 
"<a href='{$_SERVER['SCRIPT_NAME']}?p=$i'>$i</a> | ";
     }
 
?>

PDO Bumpstart Database

The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. http://xyproblem.info/

PHP Help Forum

Re: Pagination no database
« Reply #4 on: March 22, 2017, 09:47:58 pm »



PHP Help Forum

Re: Pagination no database
« Reply #5 on: March 23, 2017, 03:23:33 pm »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Well its not going too well :(

Once I see it working it will all make sence to me and i will learn more from it...

heres what i have done so far with no luck


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  function media_index($purifier, $media_id) {
  
   foreach (range(1, 40) as $value) {
   $data[] = glob(MEDIA_BASEDIR.$media_id.'/*.txt');
   $data[] = array($data => $data . $value);
   foreach ($recent_content as $media) {
   $line = file($media);
   $media_title = ($purifier->purify($line[0]));
   $date_time = basename($media);
  $date_time = basename($media, '.txt');
  $content = file_get_contents($media);
  $content = str_replace($media_title,'',$content);
  thememediatop($media_title, $media_cat, $media_id);
  $clean_data = ($purifier->purify($content));
  thememediabottom($date_time);
  }
     }
 
  usort($data, function($x, $y) {
  return $x < $y;
  });
 
  $number_of_chunks = 4;
  $data = array_chunk($data, $number_of_chunks);
  $pagecount = count($data);
 
  if (isset($_GET['p']) && (is_numeric($_GET['p']))) {
  if ($_GET['p'] > $pagecount) {
  die('<span style="color:#FF0000">Error: Page Does Not Exist</span>');
         }
  $i = $_GET['p'] - 1;
     } else {
  $i = 0;
     }
 
  print_r ($clean_data);
 
  for ($i = 1; $i <= $pagecount; $i++) {
  print "<a href='./?page=Media&id={$media_id}&p={$i}'>{$i}</a> | ";
     }
 }

i can see what its doing but i cant understand how to implement my array into this because my array is just a list of files...

any clue as to how i impement this?
Code: [Select]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    $files = array();
    $files = glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
   usort($files, function($x, $y) {
   return $x < $y;
   });
  
   foreach ($media_content as $media) {
  
  $line = file($media);
  $media_title = ($purifier->purify($line[0]));
  $date_time = basename($media);
  $date_time = basename($media, '.txt');
  $content = file_get_contents($media);
  $content = str_replace($media_title,'',$content);
 
  thememediatop($media_title, $media_cat, $media_id);
  print_r ($purifier->purify($content));
  thememediabottom($date_time);
  }

Thanks

PHP Help Forum

Re: Pagination no database
« Reply #6 on: March 23, 2017, 07:45:04 pm »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Hi i found one...
http://stackoverflow.com/questions/31353570/how-to-use-glob-brace-for-listing-only-folders-with-pagination
Code: [Select]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  $folders = glob("*", GLOB_ONLYDIR);
  usort($folders, function ($a, $b) {
  return filemtime($b) - filemtime($a);
  });
  
  $record_count  = 20;
  $total_pages   = ceil(count($folders)/$record_count);
  $page          = $_REQUEST['page']; ///make it dyanamic :: page num
  $offset        = ($page-1)*$record_count;
 $folders_filter  = array_slice($folders, $offset,$record_count);
 
 foreach ($folders_filter as $folder) {
 echo "$folder <br/>";
 }
 
 if($total_pages > 1){
    if($page != 1){
       echo '<a href="thispage.php?page='.($page-1).'">Prev</a>';
    }
    if($page != $total_pages){
       echo '<a href="thispage.php?page='.($page+1).'">Next</a>';
    }
 }



i had to update it best i can.. here is what i have working so far :)

Code: [Select]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  function media_index($purifier, $media_id) {
   if (isset($_GET['p']) && (is_numeric($_GET['p']))) {
   $p = htmlentities($_GET['p'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
   } else {
   $p = 1;
   }
   $media_files = array();
   $media_files = glob(MEDIA_BASEDIR.$media_id.'/*.txt');
   usort($media_files, function($x, $y) {
  return $x < $y;
  });
  $row_count = 1;
  $total_pages = ceil(count($media_files)/$row_count);
  $offset = ($p-1)*$row_count;
  $media_files = array_slice($media_files, $offset, $row_count);
 
  foreach ($media_files as $media) {
  $line = file($media);
  $media_title = ($purifier->purify($line[0]));
  $date_time = basename($media);
  $date_time = basename($media, '.txt');
  $content = file_get_contents($media);
  $content = str_replace($media_title,'',$content);
  thememediatop($media_title, $media_id, $media_id);
  print_r ($purifier->purify($content));
  thememediabottom($date_time);
  }
  if($total_pages > 1) {
  print ("<div style='text-align:center;'><p>Currently viewing page {$p} of {$total_pages}</p>");
  if($p != 1) {
  print ("&loarr;&nbsp;<a href='./?page=Media&id={$media_id}&p=".($p-1)."'>Prev</a>&nbsp;&hoarr;");
  }
  if($p != $total_pages) {
  print ("&nbsp;<a href='./?page=Media&id={$media_id}&p=".($p+1)."'>Next</a>&nbsp;&roarr;");
  }
  print ("</div>");
  }
 }

how dose it look? i think the code was old so not sure if ive updated it enough

thanks

PHP Help Forum

Re: Pagination no database
« Reply #7 on: March 24, 2017, 04:51:14 pm »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Hi sorry to spam befor i get my replys i have been cleaning it up

this is what i have now...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  
  
function media_index($purifier$media_id) {
  
	
$media_files = array();
  
	
$media_files glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
	
usort($media_files, function($x$y) {
  
	
return 
$x $y;
  
	
});
  
	
$row_count 3;
  
	
$total_pages ceil(count($media_files)/$row_count);
 
	
if (isset(
$_GET['p']) && (is_numeric($_GET['p']))) {
 
	
	
$p htmlentities($_GET['p'], ENT_QUOTES ENT_SUBSTITUTE'UTF-8');
 
	
	
if (
$p $total_pages) {
 
	
	
	
$p 1;
 
	
	
} else 
	
if (
$p $total_pages) {
 
	
	
	
	
	
$p 1;
 
	
	
}
 
	
} else {
 
	
	
$p 1;
 
	
}
 
	
$offset = ($p-1)*$row_count;
 
	
$media_files array_slice($media_files$offset$row_count);
 
	
foreach (
$media_files as $media) {
 
	
	
$line file($media);
 
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
$date_time basename($media);
 
	
	
$date_time basename($media'.txt');
 
	
	
$content file_get_contents($media);
 
	
	
$content str_replace($media_title,'',$content);
 
	
	
thememediatop($media_title$media_id$media_id);
 
	
	
print_r ($purifier->purify($content));
 
	
	
thememediabottom($date_time);
 
	
}
 
	
if (
$total_pages 1) {
 
	
	
print (
"<div style='text-align:center;'><p>Currently&nbsp;viewing&nbsp;page&nbsp;{$p}&nbsp;of&nbsp;{$total_pages}</p>\n");
 
	
	
if(
$p != 1) {
 
	
	
	
print (
"&loarr;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p-1)."'>Prev</a>&nbsp;&nbsp;\n");
 
	
	
}
 
	
	
if(
$p != $total_pages) {
 
	
	
	
print (
"&nbsp;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p+1)."'>Next</a>&nbsp;&roarr;\n");
 
	
	
}
 
	
	
print (
"</div>\n");
 
	
}
 }
 



ill be made up if you aprove this :)
thanks

PHP Help Forum

Re: Pagination no database
« Reply #8 on: March 25, 2017, 07:14:15 am »


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
Sorry again, ive just made more  changes

made it a propper pagination by adding the numbers so it looks like

prev 12345 next

here it is..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  function media_index($purifier$media_id) {
  
	
$media_files = array();
  
	
$media_files glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
	
usort($media_files, function($x$y) {
  
	
return 
$x $y;
  
	
});
  
	
$media_pages $media_files;
  
	
$media_pages array_combine(range(1count($media_pages)), $media_pages);
  
	
$row_count 1;
 
	
$total_pages ceil(count($media_files)/$row_count);
 
	
if (isset(
$_GET['p']) && (is_numeric($_GET['p']))) {
 
	
	
$p htmlentities($_GET['p'], ENT_QUOTES ENT_SUBSTITUTE'UTF-8');
 
	
	
if (
$p $total_pages) {
 
	
	
	
$p 1;
 
	
	
}
 
	
} else {
 
	
	
$p 1;
 
	
}
 
	
$offset = ($p-1)*$row_count;
 
	
$media_files array_slice($media_files$offset$row_count);
 
	
foreach (
$media_files as $media) {
 
	
	
$line file($media);
 
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
$date_time basename($media);
 
	
	
$date_time basename($media'.txt');
 
	
	
$content file_get_contents($media);
 
	
	
$content str_replace($media_title,'',$content);
 
	
	
thememediatop($media_title$media_id$media_id);
 
	
	
print_r ($purifier->purify($content));
 
	
	
thememediabottom($date_time);
 
	
}
 
	
print (
"<div style='text-align:center;'>");
 
	
if (
$total_pages 1) {
 
	
	
print (
"<p>Currently&nbsp;viewing&nbsp;page&nbsp;{$p}&nbsp;of&nbsp;{$total_pages}</p>\n");
 
	
	
if (
$p != 1) {
 
	
	
	
print (
"&loarr;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p-1)."'>Prev</a>&nbsp;&nbsp;\n");
 
	
	
}
 
	
	
$i 0;
 
	
	
foreach (
$media_pages as $pages=>$page) {
 
	
	
	
if (
$p != $pages) {
 
	
	
	
	
$link_name $pages;
 
	
	
	
} else {
 
	
	
	
	
$link_name = ("<strong>{$pages}</strong>");
 
	
	
	
}
 
	
	
	
print (
"&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p={$pages}'>{$link_name}</a>&nbsp;\n");
 
	
	
	
$i++;
 
	
	
}
 
	
	
if (
$p != $total_pages) {
 
	
	
	
print (
"&nbsp;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p+1)."'>Next</a>&nbsp;&roarr;\n");
 
	
	
}
 
	
}
 
	
print (
"</div>\n");
 }



thanks again !! and sorry for spamming haha

jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
im a noob i found a error with the numbers i added so i made a new one that was actualy easyer to write and smaller..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  function media_index($purifier$media_id) {
  
	
$media_files = array();
  
	
$media_files glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
	
usort($media_files, function($x$y) {
  
	
return 
$x $y;
  
	
});
  
	
$row_count 3;
  
	
$total_pages ceil(count($media_files)/$row_count);
  
	
if (isset(
$_GET['p']) && (is_numeric($_GET['p']))) {
 
	
	
$p htmlentities($_GET['p'], ENT_QUOTES ENT_SUBSTITUTE'UTF-8');
 
	
	
if (
$p $total_pages) {
 
	
	
	
$p 1;
 
	
	
}
 
	
} else {
 
	
	
$p 1;
 
	
}
 
	
$offset = ($p-1)*$row_count;
 
	
$media_files array_slice($media_files$offset$row_count);
 
	
foreach (
$media_files as $media) {
 
	
	
$line file($media);
 
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
$date_time basename($media);
 
	
	
$date_time basename($media'.txt');
 
	
	
$content file_get_contents($media);
 
	
	
$content str_replace($media_title,'',$content);
 
	
	
thememediatop($media_title$media_id$media_id);
 
	
	
print_r ($purifier->purify($content));
 
	
	
thememediabottom($date_time);
 
	
}
 
	

 
	
print (
"<div style='text-align:center;'>");
 
	
if (
$total_pages 1) {
 
	
	
print (
"<p>Currently&nbsp;viewing&nbsp;page&nbsp;{$p}&nbsp;of&nbsp;{$total_pages}</p>\n");
 
	
	
if (
$p != 1) {
 
	
	
	
print (
"&loarr;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p-1)."'>Prev</a>&nbsp;&nbsp;\n");
 
	
	
}
 
	
	
$media_pages range(1$total_pages);
 
	
	
foreach (
$media_pages as $pages) {
 
	
	
	
if (
$p != $pages) {
 
	
	
	
	
$link_name $pages;
 
	
	
	
} else {
 
	
	
	
	
$link_name = ("<strong>{$pages}</strong>");
 
	
	
	
}
 
	
	
	
print (
"&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p={$pages}'>{$link_name}</a>&nbsp;\n");
 
	
	
}
 
	
	
if (
$p != $total_pages) {
 
	
	
	
print (
"&nbsp;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p+1)."'>Next</a>&nbsp;&roarr;\n");
 
	
	
}
 
	
}
 
	
print (
"</div>\n");
 }




here is what i just wrote this...
1
2
3
4
5
6
7
8
9
10
11
  
  
	
	
$media_pages range(1$total_pages);
  
	
	
foreach (
$media_pages as $pages) {
  
	
	
	
if (
$p != $pages) {
  
	
	
	
	
$link_name $pages;
  
	
	
	
} else {
  
	
	
	
	
$link_name = ("<strong>{$pages}</strong>");
  
	
	
	
}
  
	
	
	
print (
"&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p={$pages}'>{$link_name}</a>&nbsp;\n");
 
	
	
}
 



to replace this...

1
2
3
4
5
6
7
8
9
10
11
12
13
  $media_pages $media_files;
  
$media_pages array_combine(range(1count($media_pages)), $media_pages);
  
  
$i 0;
  foreach (
$media_pages as $pages=>$page) {
  
	
if (
$p != $pages) {
  
	
	
$link_name $pages;
  
	
} else {
  
	
	
$link_name = ("<strong>{$pages}</strong>");
 
	
}
 
	
print (
"&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p={$pages}'>{$link_name}</a>&nbsp;\n");
 
	
$i++;
 }



honestly ive been on this all day i wont blame you for going mad about the spam :) cant help it :)

Thanks.

Kevin Rubio

  • Professional PHP Helper
  • Senior Member
  • *
  • Posts: 1814
  • Karma: 108
  • Programmer Available for hire
    • View Profile
    • Galaxy Internet
PDO Bumpstart Database

The XY Problem
The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. http://xyproblem.info/


jimbo

  • Regular Member
  • **
  • Posts: 78
  • Karma: 0
    • View Profile
This;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  function media_index($purifier$media_id) {
  
	
$media_files = array();
  
	
$media_files glob(MEDIA_BASEDIR.$media_id.'/*.txt');
  
	
usort($media_files, function($x$y) {
  
	
return 
$x $y;
  
	
});
  
	
$row_count 3;
  
	
$total_pages ceil(count($media_files)/$row_count);
  
	
if (isset(
$_GET['p']) && (is_numeric($_GET['p']))) {
 
	
	
$p htmlentities($_GET['p'], ENT_QUOTES ENT_SUBSTITUTE'UTF-8');
 
	
	
if (
$p $total_pages) {
 
	
	
	
$p 1;
 
	
	
}
 
	
} else {
 
	
	
$p 1;
 
	
}
 
	
$offset = ($p-1)*$row_count;
 
	
$media_files array_slice($media_files$offset$row_count);
 
	
foreach (
$media_files as $media) {
 
	
	
$line file($media);
 
	
	
$media_title = ($purifier->purify($line[0]));
 
	
	
$date_time basename($media);
 
	
	
$date_time basename($media'.txt');
 
	
	
$content file_get_contents($media);
 
	
	
$content str_replace($media_title,'',$content);
 
	
	
thememediatop($media_title$media_id$media_id);
 
	
	
print_r ($purifier->purify($content));
 
	
	
thememediabottom($date_time);
 
	
}
 
	

 
	
print (
"<div style='text-align:center;'>");
 
	
if (
$total_pages 1) {
 
	
	
print (
"<p>Currently&nbsp;viewing&nbsp;page&nbsp;{$p}&nbsp;of&nbsp;{$total_pages}</p>\n");
 
	
	
if (
$p != 1) {
 
	
	
	
print (
"&loarr;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p-1)."'>Prev</a>&nbsp;&nbsp;\n");
 
	
	
}
 
	
	
$media_pages range(1$total_pages);
 
	
	
foreach (
$media_pages as $pages) {
 
	
	
	
if (
$p != $pages) {
 
	
	
	
	
$link_name $pages;
 
	
	
	
} else {
 
	
	
	
	
$link_name = ("<strong>{$pages}</strong>");
 
	
	
	
}
 
	
	
	
print (
"&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p={$pages}'>{$link_name}</a>&nbsp;\n");
 
	
	
}
 
	
	
if (
$p != $total_pages) {
 
	
	
	
print (
"&nbsp;&nbsp;<a href='./?page=Media&amp;id={$media_id}&amp;p=".($p+1)."'>Next</a>&nbsp;&roarr;\n");
 
	
	
}
 
	
}
 
	
print (
"</div>\n");
 }