//请老师帮我看看这个下一页这样写对不对,我电脑数据库打不开,没测试
<a href="<?=$_SERVER['PHP_SELF']. '?page='. ($page-1) ?>">上一页</a>
<?php for ($i = 1; $i <= $pages; $i++):?>
<?php
$url = $_SERVER['PHP_SELF']. '?page='.$i;
$style = 'style="background:red"';
// $i 是当前的页码, $_GET['page']相同时才是要高亮的页码
$active = ($i == $_GET['page']) ? $style : null;
?>
<a href="<?=$url?>" <?=$active?>><?=$i?></a>
<?php endfor ?>
//page是当前页,pages是总页数。当前页加1,如果小于等于总页数,就返回当前页+1,如果大于总页数,就返回总页数
<?php $xyy = ($page+1)<=$pages ? ($page+1): $pages ?>
<a href="<?=$_SERVER['PHP_SELF']. '?page='. $xyy ?>">下一页</a>
<?php
use PhpMyAdmin\Plugins;
// 体彩大乐透
define('DLT_QIANS', range(1, 35));
define('DLT_HOUS', range(1, 12));
class Dlt{
// 前球
private static $dltQians = DLT_QIANS;
// 后球
private static $dltHous = DLT_HOUS;
// 前球中奖号:5/35
private static $electDltQians = [];
// 后球中奖号:2/12?
private static $electDltHous = [];
// 保存号码
public static $testNos = [];
// 从35个球选出5个
private static function createDltQians(){
for($i=0;$i<5;$i++){
// 随机取一个数,返回一个KEY
$key = array_rand(self::$dltQians);
// 将这个数添加到前球数组中
array_push(self::$electDltQians, self::$dltQians[$key]);
// 将选出的球从原始35个数中删除
array_splice(self::$dltQians, $key, 1);
}
// 排序输出
sort(self::$electDltQians, SORT_NUMERIC);
}
// 从12个数中取出2个
private static function createDltHous(){
for($i=0;$i<2;$i++){
// 随机取一个数,返回一个KEY
$key = array_rand(self::$dltHous);
// 将这个数添加到后球数组中
array_push(self::$electDltHous, self::$dltHous[$key]);
// 将选出的球从原始12个数中删除
array_splice(self::$dltHous, $key, 1);
}
// 排序输出
sort(self::$electDltHous, SORT_NUMERIC);
}
// 生成号码
private static function createTestNos($n=2){
for($i=0;$i < $n; $i++){
self:: $dltQians = DLT_QIANS;
self:: $dltHous = DLT_HOUS;
self:: $electDltQians = [];
self:: $electDltHous = [];
// 生成前球
self::createDltQians();
// 生成后球
self::createDltHous();
// 合并
self::$testNos[] = array_merge(self::$electDltQians, self::$electDltHous);
}
}
public static function getTestNos($n =2){
self::createTestNos($n);
return self::$testNos;
}
}
Dlt::getTestNos(5);
print_r(Dlt::$testNos);