wanaka
|
| Posted: 05/06/2002, 1:30 AM |
|
Hi,
Now I cannot sort the page either through name, IC or any of the field.
<?php
/*********************************************************************************
* Filename: edirectory.php
* Generated with CodeCharge 2.0.5
* PHP 4.0 build 11/30/2001
*********************************************************************************/
//-------------------------------
// edirectory CustomIncludes begin
include ("./common.php");
include ("./styles.inc");
$page_title = "List of Contact";
include("./breadcrumb.php");
// edirectory CustomIncludes end
//-------------------------------
session_start();
//===============================
// Save Page and File Name available into variables
//-------------------------------
$sFileName = "contact.php";
//===============================
//===============================
// edirectory PageSecurity begin
check_security(1);
// edirectory PageSecurity end
//===============================
//===============================
// edirectory Open Event begin
// edirectory Open Event end
//===============================
//===============================
// edirectory OpenAnyPage Event start
// edirectory OpenAnyPage Event end
//===============================
//===============================
//Save the name of the form and type of action into the variables
//-------------------------------
$sAction = get_param("FormAction");
$sForm = get_param("FormName");
//===============================
// edirectory Show begin
//===============================
// Display page
//===============================
// HTML Page layout
//-------------------------------
?><html>
<head>
<title>venus</title>
<meta name="GENERATOR" content="YesSoftware CodeCharge v.2.0.5 build 11/30/2001">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head>
<link rel="stylesheet" type="text/css" href="Style.css">
<body bgcolor="#ffffff" link="#000099" alink="#ff0000" vlink="#000099" text="#000000">
<?include ("./header.html");?>
<br>
<?php breadCrumb($SCRIPT_URL); ?>
<br>
<?php Search_show() ?>
<br>
<?php contact_show() ?>
</body>
</html>
<?php
// edirectory Show end
//===============================
// edirectory Close Event begin
// edirectory Close Event end
//===============================
//********************************************************************************
//===============================
// Display Search Form
//-------------------------------
function Search_show()
{
global $db;
global $styles;
global $sForm;
$sFormTitle = "Search";
$sActionFileName = "contact.php";
//-------------------------------
// Search Open Event begin
// Search Open Event end
//-------------------------------
//-------------------------------
// Set variables with search parameters
//-------------------------------
//-------------------------------
// Search Show begin
//-------------------------------
//-------------------------------
// Search Show Event begin
// Search Show Event end
//-------------------------------
?>
<form method="GET" action="<?= $sActionFileName ?>" name="Search">
<input type="hidden" name="FormName" value="Search"><input type="hidden" name="FormAction" value="search">
<table class="ClearFormTABLE" cellspacing="1" cellpadding="3" border="0" width="100%">
<tr>
<td width="30%" class="ClearDataTD"><input class="ClearInput" type="text" name="s_contact_name" maxlength="60" value="<?= tohtml($flds_contact_name) ?>" size="20" >
<input class="ClearButton" type="submit" value="Search">
</td>
<td class="ClearDataTD">
<a class="ClearDataLink" href="contact.php?s_contact_name=">show all</a>
</td>
</tr>
</table>
</form>
<?
//-------------------------------
// Search Show end
//-------------------------------
//-------------------------------
// Search Close Event begin
// Search Close Event end
//-------------------------------
//===============================
}
//===============================
// Display Grid Form
//-------------------------------
function contact_show()
{
//-------------------------------
// Initialize variables
//-------------------------------
global $db;
global $scontactErr;
global $sFileName;
global $styles;
$sWhere = "";
$sOrder = "";
$sSQL = "";
$sFormTitle = "Customer Contact";
$HasParam = false;
$iSort = "";
$iSorted = "";
$sDirection = "";
$sSortParams = "";
$transit_params = "s_contact_name=" . tourl(get_param("s_contact_name")) . "&";
$form_params = "s_contact_name=" . tourl(get_param("s_contact_name")) . "&";
//-------------------------------
// Build ORDER BY statement
//-------------------------------
$sOrder = " order by c.contact_name Asc";
$iSort = get_param("Formcontact_Sorting");
$iSorted = get_param("Formcontact_Sorted");
if(!$iSort)
{
$form_sorting = "";
}
else
{
if($iSort == $iSorted)
{
$form_sorting = "";
$sDirection = " DESC";
$sSortParams = "Formcontact_Sorting=" . $iSort . "&Formcontact_Sorted=" . $iSort . "&";
}
else
{
$form_sorting = $iSort;
$sDirection = " ASC";
$sSortParams = "Formcontact_Sorting=" . $iSort . "&Formcontact_Sorted=" . "&";
}
if ($iSort == 1) $sOrder = " order by contact.contact_name" . $sDirection;
if ($iSort == 2) $sOrder = " order by contact.contact_IC" . $sDirection;
if ($iSort == 3) $sOrder = " order by cust_name" . $sDirection;
if ($iSort == 4) $sOrder = " order by type_short_desc" . $sDirection;
if ($iSort == 5) $sOrder = " order by contact_mobile" . $sDirection;
if ($iSort == 6) $sOrder = " order by contact_office" . $sDirection;
if ($iSort == 7) $sOrder = " order by contact_pager" . $sDirection;
if ($iSort == 8) $sOrder = " order by contact_home" . $sDirection;
if ($iSort == 9) $sOrder = " order by contact_fax" . $sDirection;
if ($iSort == 10) $sOrder = " order by contact_email" . $sDirection;
}
//-------------------------------
// HTML column headers
//-------------------------------
?>
<table cellpadding="3" cellspacing="1" border="0" class="ClearFormTABLE">
<tr>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=1&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Name</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=2&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>IC</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=3&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Customer</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=4&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Type</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=5&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>HP</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=6&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Office</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=7&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Pager</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=8&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Home</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=9&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Fax</font></a></td>
<td nowrap class="ClearColumnTD"><a href="<?=$sFileName?>?<?=$form_params?>Formcontact_Sorting=10&Formcontact_Sorted=<?=$form_sorting?>&"><font <?= $styles["ColumnFONT"] ?>>Email</font></a></td>
</tr>
<?
//-------------------------------
// Build WHERE statement
//-------------------------------
$ps_contact_name = get_param("s_contact_name");
if(strlen($ps_contact_name))
{
$HasParam = true;
$sWhere = "contact_name like " . tosql("%".$ps_contact_name ."%", "Text") . " or " . "cust_name like " . tosql("%".$ps_contact_name ."%", "Text");
}
if($HasParam)
$sWhere = " AND (" . $sWhere . ")";
//-------------------------------
// Build base SQL statement
//-------------------------------
$sSQL = "SELECT contact_id, contact_name, contact_IC, contact_mobile, contact_office, contact_pager, contact_home, contact_fax, contact.cust_id, contact_email, contact.contact_type_id, type_short_desc, cust_name FROM (contact INNER JOIN contact_category ON contact.contact_type_id = contact_category.contact_type_id) INNER JOIN customer ON contact.cust_id = customer.cust_id";
$sOrder = "";
//-------------------------------
//-------------------------------
// contact Open Event begin
// contact Open Event end
//-------------------------------
//-------------------------------
// Assemble full SQL statement
//-------------------------------
$sSQL .= $sWhere . $sOrder;
//-------------------------------
//-------------------------------
// Execute SQL statement
//-------------------------------
$db->query($sSQL);
$next_record = $db->next_record();
//-------------------------------
// Process empty recordset
//-------------------------------
if(!$next_record)
{
?>
<tr>
<td colspan="10" class="ClearAltDataTD">No records</td>
</tr>
<?
?>
</table>
<?
return;
}
//-------------------------------
//-------------------------------
// Display grid based on recordset
//-------------------------------
while($next_record )
{
//-------------------------------
// Create field variables based on database fields
//-------------------------------
$fldcontact_email = $db->f("contact_email");
$fldcontact_fax = $db->f("contact_fax");
$fldcontact_home = $db->f("contact_home");
$fldcontact_IC = $db->f("contact_IC");
$fldcontact_id = $db->f("contact_id");
$fldcontact_mobile = $db->f("contact_mobile");
$fldcontact_name = $db->f("contact_name");
$fldcontact_office = $db->f("contact_office");
$fldcontact_pager = $db->f("contact_pager");
$fldcontact_type_id = $db->f("type_short_desc");
$fldcust_id = $db->f("cust_name");
$fldcust_key = $db->f("cust_id");
$next_record = $db->next_record();
//-------------------------------
// contact Show begin
//-------------------------------
//-------------------------------
// contact Show Event begin
// contact Show Event end
//-------------------------------
//-------------------------------
// Process the HTML controls
//-------------------------------
?>
<tr>
<td class="ClearDataTD">
<?if (get_session("UserRights") ==1)
{
echo "$fldcontact_name";
}
else
{
echo "<a class=\"ClearDataLink\" href=addcontact.php?contact_id=$fldcontact_id>$fldcontact_name</a> ";
}
?>
</td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_IC) ?> </td>
<td class="ClearDataTD">
<?if (get_session("UserRights") ==1)
{
echo "$fldcust_id";
}
else
{
echo "<a class=\"ClearDataLink\" href=addcustomer.php?cust_id=$fldcust_key>$fldcust_id</a> ";
}
?>
</td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_type_id) ?> </td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_mobile) ?> </td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_office) ?> </td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_pager) ?> </td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_home) ?> </td>
<td class="ClearDataTD">
<?= tohtml($fldcontact_fax) ?> </td>
<td class="ClearDataTD">
<a href="mailto:<?=$fldcontact_email?>"><?= tohtml($fldcontact_email) ?></a> </td>
</tr><?
//-------------------------------
// contact Show end
//-------------------------------
//-------------------------------
// Move to the next record
//-------------------------------
}
//-------------------------------
// Finish form processing
//-------------------------------
?>
</table>
<?
//-------------------------------
// contact Close Event begin
// contact Close Event end
//-------------------------------
}
//===============================
?>
|
|
|
 |
Nicole
|
| Posted: 05/07/2002, 2:32 AM |
|
Hello,
could you provide more details about the problem you've got?
|
|
|
 |
wanaka
|
| Posted: 05/07/2002, 5:32 AM |
|
Hi,
I remove the $where="" and it work now
|
|
|
 |
|