-2

I'm trying to get page number from web address like beds.html?page=3

but, if I use php get method, then it's not returning anything.

I hope to find any easy solution.

cheers

ahmed
  • 15
  • 5

3 Answers3

0

you can get page like this:

<?php 
$_REQUEST['page']; 
?>

and also you can type echo before $|_REQUEST to check you are getting proper page number or not

0

get is the right method to use.

<?php 
  $_GET['page']; 
?>
Ish
  • 2,085
  • 3
  • 21
  • 38
  • Don't forget about XSS attacks. Check the value of $_GET['page']. – Scriptman Sep 08 '16 at 12:19
  • cheers mate, but get and request method is not working. i have use mode_rewrite to generate html pages ( not php ) it is .html – ahmed Sep 08 '16 at 12:28
0

If You Want that parameter on html page then you have to use javascript for it

<script>
    var param1var = getQueryVariable("page");

    function getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      } 
      alert('Query Variable ' + variable + ' not found');
    }
    </script>

if you are on php page simply use

<?php 
 echo  $_GET['page']; 
?>
Vishnu Bhadoriya
  • 1,655
  • 1
  • 20
  • 28