dongyakui8675 2012-05-07 18:35
浏览 44
已采纳

我的分页脚本中的链接在第1页后消失

Me back again whit a PHP mySQLi pagination problem... When I rune the script it works fine for first page, but when y click on the link to the second pages te links works but the pagination disappears. so if I have 3 links now I see none. Here's my code.

<?php

    include_once ('myConnection.php');

    if ( isset( $_GET["get_name"] ) ) { 
        $las_escuelas = $_GET["get_name"];
    } else { 
        $las_escuelas = 1; 
    };

    $start_from = ( $las_escuelas - 1 ) * 10;

    $escuelas = "SELECT * 
                   FROM escuelas 
                   WHERE delegacion = '$delegacion' 
                     AND nivel = '$nivel' 
                   ORDER BY nombre ASC 
                   LIMIT $start_from, 10";

    $consulta = mysqli_query( $miguia, $escuelas ) or die ( mysqli_error() );

    while ( $fila = mysqli_fetch_array( $consulta ) ) {
        echo $fila['name'] . '<br>' . $fila['street'] . ' ' . $fila['numero'] . ' ' . $fila['place'] . ' ' . $fila['phone'] . '<br>';
    };

    $escuelas = "SELECT COUNT(delegacion) 
                   FROM escuelas 
                   WHERE delegacion = '$delegacion' 
                     AND nivel = '$nivel'";

    $consulta = mysqli_query( $miguia, $escuelas );
    $fila = mysqli_fetch_row( $consulta );
    $registros_total = $fila[0];
    $paginas_total = ceil( $registros_total / 10 );

    for ( $i = 1; $i <= $paginas_total; $i++ ) {
        echo "<a href='resultados1.php?las_escuelas=".$i."'>".$i."</a> ";
    };

?>

Thank's :)

  • 写回答

1条回答 默认 最新

  • douhuang7263 2012-05-07 18:55
    关注

    I think (it's pretty hard to "reverse engineer Spanish code :) that you should start your for cycle from $i = 0 instead of 1.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?