Jump to content
Larry Ullman's Book Forums

Pagination Problems With <Ul><Li>


Recommended Posts

Hi everyone,

 

I'm on chapter 10 right now, 

 

I want to add some style to the pagination using <ul> and <li>,

 

i'm trying this way...

if ($pages > 1) {

	echo '<ul class="pagination margin-none pull-right"><li>';

	$current_page = ($start/$display) + 1;

	if($current_page != 1){
		echo '<a href="view_users.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
	}


	for($i = 1; $i <= $pages; $i++){
		if($i != $current_page){
			echo '<a href="view_users.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
		} else {
			echo $i . ' ';
		}
	}

	if($current_page != $pages){
		echo '<a href="view_users.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
	}

	echo '</li></ul>';
}

this is how i see it

 

pagination.png

 

how can i solve this? thanks!

 

Link to comment
Share on other sites

asanti, please look at my question in my first post again and answer it in kind.

Thank you.

 

Let me know if i understand you ok,

<ul class="pagination margin-none pull-right">
										<li class="disabled"><a href="#">«</a></li>
										<li class="active"><a href="#">1</a></li>
										<li><a href="#">2</a></li>
										<li><a href="#">3</a></li>
										<li><a href="#">5</a></li>
										<li><a href="#">6</a></li>
										<li><a href="#">7</a></li>
										<li><a href="#">»</a></li>
									</ul>

CSS

.pagination {
display: inline-block;
padding-left: 0;
margin: 20px 0;
border-radius: 4px;
}
.pull-right {
float: right!important;
}
.margin-none {
margin: 0 !important;
}
Link to comment
Share on other sites

the markup is in my first post with the actual result.

 

this is my complete .php file

<?php
require_once ('inc/db.php');
//include_once ('inc/funciones.php');


$display = 10;

if (isset($_GET['p']) && is_numeric($_GET['p'])) {
	
	$pages = $_GET['p'];
	
	} else {
	
	$q = "SELECT COUNT(id_aviso) FROM avisos WHERE fecha_moderado IS NOT NULL ORDER BY fecha_creado DESC";
	$r = @mysqli_query($dbc, $q);
	$row = @mysqli_fetch_array($r, MYSQLI_NUM);
	$records = $row[0];

	if ($records > $display){
		$pages = ($records % $display == 0) ? ($records/$display) : ceil($records/$display);
	} else {
		$pages = 1;
	}

}


if (isset($_GET['s']) && is_numeric($_GET['s'])){
		
	$start = $_GET['s'];

	} else {

	$start= 0;

	}			



$q = "SELECT titulo, descripcion, DATE_FORMAT(fecha_creado, '%d %M, %Y') AS fc, id_aviso FROM avisos WHERE fecha_moderado IS NOT NULL ORDER BY fecha_creado DESC LIMIT $start, $display";
$r = @mysqli_query ($dbc, $q);

$num = mysqli_num_rows($r);


$foto = 'imagenes/fotos_avisos/random5.png';

 

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){
		echo '<div class="media margin-none">
				<a class="pull-left bg-inverse innerAll text-center" href="#"><img src="' . $foto . '" share_alt="" width="100"></a>
				<div class="media-body innerAll">
				<h4 class="media-heading innerT">
				
				<a href="' . sanitizarURL($row['titulo']) .'-da' . $row['id_aviso'] . '" class="text-inverse">' . substr($row['titulo'], 0, 60) . '</a> <span class="text-small pull-right"><i class="fa fa-fw fa-calendar-o"></i> ' . $row['fc'] . '</span></h4>											
				
				<p>' . substr($row['descripcion'], 0, 80) . ' ...</p>
				
				<h4><span class="text-small"><i class="fa fa-fw fa-map-marker"></i> Capital Federal</span></h4>
				</div>
				</div>
				<div class="col-separator-h"></div>';
			}
			
		echo '';		
		mysqli_free_result($r);		

		mysqli_close($dbc);




if ($pages > 1) {

	echo '<li>';

	$current_page = ($start/$display) + 1;

	
	if($current_page != 1){
		echo '<a href="convocatorias.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
	}


	for($i = 1; $i <= $pages; $i++){
		if($i != $current_page){
			echo '<a href="convocatorias.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
		} else {
			echo $i . ' ';
		}
	}

	if($current_page != $pages){
		echo '<a href="convocatorias.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
	}

	echo '</li>';
}



?>	
Link to comment
Share on other sites

Please read my previous post.

The resulting markup did not match the displayed image at all.

 

I don't want to see the PHP code, I want to see resulting markup and CSS, and an accurate picture of the problem with the corresponding markup.

 

Thank you.

Link to comment
Share on other sites

 Share

×
×
  • Create New...