0

I have 2 pages

The first page for calling a second page to get all records from database, like this:

<script language="JavaScript">
       var HttPRequest = false;

       function doCallAjax(Mode,users_ID) {
          HttPRequest = false;
          if (window.XMLHttpRequest) { // Mozilla, Safari,...
             HttPRequest = new XMLHttpRequest();
             if (HttPRequest.overrideMimeType) {
                HttPRequest.overrideMimeType('text/html');
             }
          } else if (window.ActiveXObject) { // IE
             try {
                HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
             } catch (e) {
                try {
                   HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
             }
          } 

          if (!HttPRequest) {
             alert('Cannot create XMLHTTP instance');
             return false;
          }

          var url = 'AjaxDeleteRecord.php';
          var pmeters = "tMode=" + Mode +
                        "&tusers_ID=" + users_ID;

            HttPRequest.open('POST',url,true);

            HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            HttPRequest.setRequestHeader("Content-length", pmeters.length);
            HttPRequest.setRequestHeader("Connection", "close");
            HttPRequest.send(pmeters);


            HttPRequest.onreadystatechange = function()
            {

                 if(HttPRequest.readyState == 3)  // Loading Request
                  {
                   document.getElementById("mySpan").innerHTML = "Now is Loading...";
                  }

                 if(HttPRequest.readyState == 4) // Return Request
                  {
                   document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
                  }

            }

       }
    </script>
<body Onload="JavaScript:doCallAjax('LIST','');">
<form name="frmMain">
<div style="margin-right:10px">
<span id="mySpan"></span>
</div>

and the second page is php that fetches data:

$strMode = $_POST["tMode"];
$users_ID = $_POST["tusers_ID"];


if($strMode == "DELETE")
{
    //$strSQL = "DELETE FROM users , stores WHERE users.users_StoreId=stores.stores_ID AND users.users_ID = '".$users_ID."'";
    $strSQL = "update users set users_delete='1' where users.users_ID = '".$users_ID."'";
    $objQuery = mysql_query($strSQL) or die (mysql_error());
}


$strSQL = "SELECT * FROM users , stores WHERE users.users_StoreId=stores.stores_ID and users.users_delete='0' ORDER BY stores.stores_Name , users.users_Type ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");

The problem that I cannot make paging work for this.

Can any one help me?

Artem Barger
  • 40,769
  • 9
  • 59
  • 81
  • What's `HttP`? I just know `HTTP`. And `javascript:` does not belong into any `onsomething` handlers. – ThiefMaster Oct 25 '12 at 10:26
  • please check the following link http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html It is simple – mymotherland Oct 25 '12 at 10:26
  • You are using [an obsolete database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also exposing yourself to [SQL injection attacks](http://bobby-tables.com/) that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Oct 25 '12 at 10:29
  • what do you meen about database API ?? –  Oct 25 '12 at 20:19

1 Answers1

0

Use Google's Visualization API's table chart Visualization: Table.

It will automatically enable paging as per your count like 10 or 20 and sorting your content ascending or descending on the basis of column.

Master Mind
  • 2,386
  • 3
  • 31
  • 48