Hey Barbarian,
Thanks for reply bro,
Below are my code :
test.php
<?php
/**********************************************************************
test.php
***********************************************************************/
$page_security = 'SA_TESTENTRY';
$path_to_root = "..";
include($path_to_root . "/includes/db_pager.inc");
include($path_to_root . "/includes/session.inc");
page(_($help_context = "Manage Test"),@$_REQUEST['popup']);
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/testsarea/test_db.inc");
simple_page_mode(true);
//-------------------------------------------------------------------------------------------------
function can_process()
{
if (strlen($_POST['testname']) == 0)
{
$input_error = 1;
display_error( _("Please name cannot be empty."));
set_focus('testname');
return false;
}
return true;
}
function edit_link($row) {
return button("Edit".$row["id"],_("Edit"), '', ICON_EDIT);
}
}
function del_link($row) {
return button("Delete".$row["id"],_("Delete"), '', ICON_DELETE);
}
}
function select_link($row) {
return button("Select".$row["id"], $row["id"], '', ICON_ADD, 'selector');
}
//-------------------------------------------------------------------------------------------------
if ($Mode=='ADD_ITEM'){
if (can_process()){
add_namelist($_POST['testname']);
display_notification_centered(_("The details has been added."));
$Mode = 'RESET';
}
}
//-------------------------------------------------------------------------------------------------
if ($Mode == 'RESET'){
$selected_id = -1;
$sav = get_post('show_inactive');
unset($_POST); // clean all input fields
$_POST['show_inactive'] = $sav;
}
start_form();
start_outer_table(TABLESTYLE2, "width=80%");
table_section(1);
ref_cells(_("name:"), 'name_search', '',null, '', true);
table_section(2);
submit_cells('Search', _("Search"),'',_('Search Kapan'), 'default');
end_outer_table(); // outer table
$result = get_test(get_post('name_search'));
$cols = array(
_("ID")=>array('align'=>'center','ord'=>''),
_("Test name ")=>array('align'=>'center','name'=>'testname','ord'=>''), // i tried even with name=>'fieldname' -- local working , but on my server its not working
_("Added Date")=>array('align'=>'center'),
' '=> array('insert'=>true, 'fun'=>'select_link'),
array('insert'=>true, 'fun'=>'edit_link'),
array('insert'=>true, 'fun'=>'del_link'));
if (!@$_REQUEST['popup']) {
$cols[' '] = 'skip';
}
$table =& new_db_pager('test_table', $result, $cols);
$table->width = "95%";
display_db_pager($table);
echo '<br \ >';
//-------------------------------------------------------------------------------------------------
start_table(TABLESTYLE2);
if ($selected_id != -1)
{
if ($Mode == 'Edit') {
//editing an existing User
$myrow = get_namelisting($selected_id);
$_POST['id'] = $myrow["id"];
$_POST['testname'] = $myrow["testname"];
}
hidden('selected_id', $selected_id);
hidden('id');
start_row();
}
textnumber_cells(_("Name: "), 'testname',NULL,'',4);
end_table(1);
submit_add_or_update_center($selected_id == -1, '', 'both');
end_form();
end_page(@$_REQUEST['popup']);
?>
//----
test_db.php
function add_namelist($name)
{
$added_date = myowndate();
$sql = "INSERT INTO ".TB_PREF."test_table (testname, datetime)
VALUES (".db_escape($name).", ".db_escape($added_date).")";
return db_query($sql, "could not add details for $name");
}
//===============
function get_test ($name = '') {
$sql = "SELECT id,testname,datetime FROM ".TB_PREF."test_table WHERE 1=1 ";
if($name){
$sql .= " AND testname LIKE ". db_escape("%$name%");
}
return $sql;
}
//-----
function get_namelisting($id)
{
$sql = "SELECT * FROM ".TB_PREF."test_table WHERE id=".db_escape($id);
$result = db_query($sql, "could not get details $id");
return db_fetch($result);
}
//
pls have look on above code .. i dont have option to upload any file , hence puted all code here.. waiting