douxun4860 2017-12-29 10:13
浏览 66

多个php在一个页面中设置

I'm trying to achieve multiple pagination in one page.
The pagination for all the results, is working.
But except from the main results, i want to include different options.
For example, in the image below i have three more options,
Newest, Reputation, Oldest
enter image description here

So, i want multiple pagination for all these options.
In the page that i want to display the results, i have multiple isset(), in order to achieve that.

<div id='paginationUsers'>
  <?php
  //for all the results that displaying first.
  if(isset($_GET['page'])) {
    $page = $_GET['page'];
  } else {
    $page = 1;
  }
  echo "<input type='hidden' id='pageAll' value='".$page."'>";
  // for the Newest results
  if(isset($_GET['pageNewest'])) {
    $pageNewest = $_GET['pageNewest'];
    } else {
    $pageNewest = 1;
  }
  echo "<input type='hidden' id='newPage' value='".$pageNewest."'>";
  //for the Oldest results
  if(isset($_GET['pageOldest'])) {
    $pageOldest = $_GET['pageOldest'];
  } else {
    $pageOldest = 1;
  }
    echo "<input type='hidden' id='oldPage' value='".$pageOldest."'>";
    //for the Reputation results
    if(isset($_GET['pageReputation'])) {
      $pageReputation = $_GET['pageReputation'];
    } else {
      $pageReputation = 1;
    }
    echo "<input type='hidden' id='reputationPage' value='".$pageReputation."'>";
  ?>
</div>

Ofcourse, in that way cannot work as you can see in the code.
So, is it possible to include multiple isset in one page?

  • 写回答

1条回答 默认 最新

  • dongling5411 2017-12-29 10:27
    关注

    Try this code:

    <?php
    
    function getGET($name) {
        if (isset($_GET[$name]) {
        return $_GET[$name];
        } else {
        return 1;
        }
    }
    
    function genInput($id, $name) {
        return "<input type='hidden' id='". $id ."' value='". getGET($name) ."'>";
    }
    
    echo "<input type='hidden' id='pageAll' value='". getGet('page')."'>";
    
    echo genInput('newPag', 'pageNewest');
    echo genInput('oldPage', 'pageOldest');
    echo genInput('', 'pageReputation');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100