ahmed ahmed - 2 months ago 7
HTML Question

How to obtain page number from html web address

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

Answer

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']; 
?>
Comments