Blogger Information
Blog 35
fans 0
comment 0
visits 16655
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
大乐透和分页的上下页
手机用户311660634
Original
799 people have browsed it
  1. //请老师帮我看看这个下一页这样写对不对,我电脑数据库打不开,没测试
  2. <a href="<?=$_SERVER['PHP_SELF']. '?page='. ($page-1) ?>">上一页</a>
  3. <?php for ($i = 1; $i <= $pages; $i++):?>
  4. <?php
  5. $url = $_SERVER['PHP_SELF']. '?page='.$i;
  6. $style = 'style="background:red"';
  7. // $i 是当前的页码, $_GET['page']相同时才是要高亮的页码
  8. $active = ($i == $_GET['page']) ? $style : null;
  9. ?>
  10. <a href="<?=$url?>" <?=$active?>><?=$i?></a>
  11. <?php endfor ?>
  12. //page是当前页,pages是总页数。当前页加1,如果小于等于总页数,就返回当前页+1,如果大于总页数,就返回总页数
  13. <?php $xyy = ($page+1)<=$pages ? ($page+1): $pages ?>
  14. <a href="<?=$_SERVER['PHP_SELF']. '?page='. $xyy ?>">下一页</a>
  1. <?php
  2. use PhpMyAdmin\Plugins;
  3. // 体彩大乐透
  4. define('DLT_QIANS', range(1, 35));
  5. define('DLT_HOUS', range(1, 12));
  6. class Dlt{
  7. // 前球
  8. private static $dltQians = DLT_QIANS;
  9. // 后球
  10. private static $dltHous = DLT_HOUS;
  11. // 前球中奖号:5/35
  12. private static $electDltQians = [];
  13. // 后球中奖号:2/12?
  14. private static $electDltHous = [];
  15. // 保存号码
  16. public static $testNos = [];
  17. // 从35个球选出5个
  18. private static function createDltQians(){
  19. for($i=0;$i<5;$i++){
  20. // 随机取一个数,返回一个KEY
  21. $key = array_rand(self::$dltQians);
  22. // 将这个数添加到前球数组中
  23. array_push(self::$electDltQians, self::$dltQians[$key]);
  24. // 将选出的球从原始35个数中删除
  25. array_splice(self::$dltQians, $key, 1);
  26. }
  27. // 排序输出
  28. sort(self::$electDltQians, SORT_NUMERIC);
  29. }
  30. // 从12个数中取出2个
  31. private static function createDltHous(){
  32. for($i=0;$i<2;$i++){
  33. // 随机取一个数,返回一个KEY
  34. $key = array_rand(self::$dltHous);
  35. // 将这个数添加到后球数组中
  36. array_push(self::$electDltHous, self::$dltHous[$key]);
  37. // 将选出的球从原始12个数中删除
  38. array_splice(self::$dltHous, $key, 1);
  39. }
  40. // 排序输出
  41. sort(self::$electDltHous, SORT_NUMERIC);
  42. }
  43. // 生成号码
  44. private static function createTestNos($n=2){
  45. for($i=0;$i < $n; $i++){
  46. self:: $dltQians = DLT_QIANS;
  47. self:: $dltHous = DLT_HOUS;
  48. self:: $electDltQians = [];
  49. self:: $electDltHous = [];
  50. // 生成前球
  51. self::createDltQians();
  52. // 生成后球
  53. self::createDltHous();
  54. // 合并
  55. self::$testNos[] = array_merge(self::$electDltQians, self::$electDltHous);
  56. }
  57. }
  58. public static function getTestNos($n =2){
  59. self::createTestNos($n);
  60. return self::$testNos;
  61. }
  62. }
  63. Dlt::getTestNos(5);
  64. print_r(Dlt::$testNos);
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post