asanti Posted August 17, 2014 Share Posted August 17, 2014 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 how can i solve this? thanks! Link to comment Share on other sites More sharing options...
HartleySan Posted August 17, 2014 Share Posted August 17, 2014 Hello and welcome to the forums. It's very likely a CSS issue. Please post your generated HTML markup and related CSS. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted August 17, 2014 Share Posted August 17, 2014 I imagine you're having this problem because the 1 is not linked as an , which is why it's not styled the same. I also think it's pretty weird to do an UL but but everything within a single Link to comment Share on other sites More sharing options...
asanti Posted August 17, 2014 Author Share Posted August 17, 2014 i'm using bootstrap, http://getbootstrap.com/components/#pagination 1 is not linked as an <a>? mmm... how can i solve this? i think is related to the php code, could it be? Link to comment Share on other sites More sharing options...
HartleySan Posted August 18, 2014 Share Posted August 18, 2014 asanti, please look at my question in my first post again and answer it in kind. Thank you. Link to comment Share on other sites More sharing options...
asanti Posted August 18, 2014 Author Share Posted August 18, 2014 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 More sharing options...
HartleySan Posted August 19, 2014 Share Posted August 19, 2014 That markup would not produce the problem in your original post. Your original post has 1, 2, 3 and "Next", which your markup does not. Please post the markup with the actual results it produces. Thank you. Link to comment Share on other sites More sharing options...
asanti Posted August 19, 2014 Author Share Posted August 19, 2014 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 More sharing options...
HartleySan Posted August 19, 2014 Share Posted August 19, 2014 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 More sharing options...
Recommended Posts