Login   Register  
PHP Classes
elePHPant
Icontem

File: paging.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Idrak Dareshani  >  Paging Object  >  paging.php  >  Download  
File: paging.php
Role: Example script
Content type: text/plain
Description: sample page
Class: Paging Object
Display MySQL query results on a sortable grid
Author: By
Last change: added $con in drawGrid method
Date: 2009-02-20 22:22
Size: 3,347 bytes
 

Contents

Class file image Download
<http>
<head><title>PHP Grid Example</title>
<script language="javascript">
function clearFields(formObj)
{
    if (formObj.name == 'topics')
    {
        document.topics.txtId.value = "";
        document.topics.txtName.value = "";
        document.topics.txtCategory.value = "";
        document.topics.txtUrl.value = "";
        
        document.topics.topics_fid.value = "";
        document.topics.topics_fvalue.value = "";

        document.topics.topics_startrow.value = 0;
        document.topics.topics_startpage.value = 1;
        document.topics.topics_currentpage.value = 1;
        document.topics.topics_endpage.value = 10;
        document.topics.topics_rowcount.value = 10;
        
        document.topics.submit();
    }
}

function refreshPaging()
{
    document.topics.topics_fid.value = "";
    document.topics.topics_fvalue.value = "";

    document.topics.topics_startrow.value = 0;
    document.topics.topics_startpage.value = 1;
    document.topics.topics_currentpage.value = 1;
    document.topics.topics_endpage.value = 10;
    document.topics.topics_rowcount.value = 10;
    
    document.topics.submit();
}

function editRecord(editId, editId2)
{
    alert(editId);
    alert(editId2);
}
function deleteRecord(deleteId, editId2)
{
    alert(deleteId);
    alert(editId2);
}
function viewDetails(viewId, viewId2)
{
    alert(viewId);
    alert(viewId2);
}
</script>
</head>
<body>
<h2>PHP Grid Example</h2>
<?php

require_once('pagingObj.php');

$server 'localhost'$userid 'root'$password 'artec5'$database 'mysql';
$con mysql_connect($server$userid$password);

if (!
$con)
    die(
mysql_error());

if (!
mysql_select_db($database$con))
    die(
mysql_error());

//search fields
$findByName = isset($_POST['txtName']) ? $_POST['txtName'] : '';
$findById = isset($_POST['txtId']) ? $_POST['txtId'] : '';
$findByCatgory = isset($_POST['txtCategory']) ? $_POST['txtCategory'] : '';
$findByUrl = isset($_POST['txtUrl']) ? $_POST['txtUrl'] : '';

?>
<form name="topics" action="<?php echo $PHP_SELF ?>" method="post">

Id: <input type="text" name="txtId" size="10" value="<?php echo $findById ?>" />
Name: <input type="text" name="txtName" size="20" value="<?php echo $findByName ?>" />
Category: <input type="text" name="txtCategory" size="20" value="<?php echo $findByCatgory ?>" />
URL: <input type="text" name="txtUrl" size="20" value="<?php echo $findByUrl ?>" />
<input type="button" name="btnSubmit" value="Search" onclick="refreshPaging()" />

<?php

$id_field 
'help_topic_id';
$fieldNames = array('Topic Id','Category''Topic Name','URL');
$fieldSizes = array(5151850);
$fieldAlign = array('center','left','left','left');
$fields = array('help_topic_id''help_category_id''name''url');
$table 'help_topic';
$buttons = array('edit' => true'delete' => true'view' => true
        
'keys' => array('help_topic_id''help_category_id'));

$arguments = array('id_field' => $id_field'fieldNames' => $fieldNames'fieldSizes' => $fieldSizes
        
'fieldAlign' => $fieldAlign'fields' => $fields'table' => $table'buttons' => $buttons);
$clause "help_topic_id LIKE '$findById%' AND name LIKE '$findByName%' 
        AND help_category_id LIKE '
$findByCatgory%' AND url LIKE '%$findByUrl%'";

$obj = new MyPHPGrid('topics');
$obj->drawGrid($arguments$clause$con);

?>
</form>

<?php
mysql_close
();
?>

</body>
</html>