Hi,
okay im new to coding and got thrown in by my manager straight into .php without even looking at basic..

I have included my coding for a standalone webpage that is to be placed onto the IT systems purely to disect the php helpdesk ticket system and display the results as needed in a dynamic table.

how do i get the page to only display the results from the date range and then sort it by the drop down menu based purley on the "updated" data range in the table which is the date the tickets was closed???

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style2 {
	font-size: 36px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style4 {font-weight: bold}
.style6 {font-weight: bold}
-->
</style>
<
</head>

<?php require_once('Connections/helpdesk.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_helpdesk, $helpdesk);
$query_Recordset1 = "SELECT admin_user, `update`, status, opened, `group` FROM phpdesk_tickets ORDER BY `update` ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $helpdesk) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_helpdesk, $helpdesk);
$query_Recordset1 = "SELECT admin_user, `update`, status, opened, `group` FROM phpdesk_tickets ORDER BY `update` ASC";
$Recordset1 = mysql_query($query_Recordset1, $helpdesk) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>


<body>
<div align="center">
  <p><img src="images/helpdesk.jpg" width="318" height="74" /></p>
 
  <p class="style2">STATISTICS</p>
</div>

<div align="center"></div>
<div align="center"></div>
<p align="center"><strong>SELECT DATE RANGE TO SEARCH WITHIN.</strong></p>
<form id="form3" name="form3" method="post" action="">
  <label>
  <div align="center"><strong>STARTING : 
    <input name="START" type="text" id="START" value="<?php echo $row_Recordset1['update']; ?>" />
  </strong><strong>ENDING : </strong>
  <input name="END" type="text" id="END" value="<?php echo $row_Recordset1['update']; ?>" />
  <div align="center"></div>
  <label> </label>
  </div>
  </label>
  <div align="center">
    <input type="submit" name="SEARCH" id="SEARCH" value="Submit" />
  </div>
  <div align="center"></div>
  <label>
  <div align="center"></div>
  <div align="center"></div>
  <div align="center"></div>
  </label>
  
  <span id="spryselect1">
  <label>
  <div align="center"><span id="spryselect1">
    <select name="SORT" id="SORT">
      <option value="admin_user" <?php if (!(strcmp("admin_user", $row_Recordset1['']))) {echo "selected=\"selected\"";} ?>>ADMIN_USER</option>
      <option value="status" <?php if (!(strcmp("status", $row_Recordset1['']))) {echo "selected=\"selected\"";} ?>>STATUS</option>
      <option value="update" <?php if (!(strcmp("update", $row_Recordset1['']))) {echo "selected=\"selected\"";} ?>>UPDATE</option>
      <option value="opened" <?php if (!(strcmp("opened", $row_Recordset1['']))) {echo "selected=\"selected\"";} ?>>OPENED</option>
      <option value="group" <?php if (!(strcmp("group", $row_Recordset1['']))) {echo "selected=\"selected\"";} ?>>GROUP</option>
    </select>
  </span>
    <p>&nbsp;</p>
  </div>
  <div align="center"><span id="spryselect1">
    </label>
    </span>
  </div>
  <table border="1" align="center">
    <tr>
      <td><span id="spryselect1">admin_user</span></td>
      <td><span id="spryselect1">update</span></td>
      <td><span id="spryselect1">status</span></td>
      <td><span id="spryselect1">opened</span></td>
      <td><span id="spryselect1">group</span></td>
    </tr>
    <?php do { ?>
      <tr>
        <td><span id="spryselect1"><?php echo $row_Recordset1['admin_user']; ?></span></td>
        <td><span id="spryselect1"><?php echo $row_Recordset1['update']; ?></span></td>
        <td><span id="spryselect1"><?php echo $row_Recordset1['status']; ?></span></td>
        <td><span id="spryselect1"><?php echo $row_Recordset1['opened']; ?></span></td>
        <td><span id="spryselect1"><?php echo $row_Recordset1['group']; ?></span></td>
      </tr>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
  <div align="center"></div>
  <div align="center"></div>
</form>
<p align="center">&nbsp;</p>
<script type="text/javascript">
<!--
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
//-->
  </script>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset1);

mysql_free_result($Recordset1);
?>

Mysql

$query_Recordset1 = "SELECT admin_user, `update`, status, opened, `group` FROM phpdesk_tickets WHERE update between $date1 and $date2 ORDER BY `update` ASC";

and the date1 date2 fields are input from a html form, or calculated as date() -14 for two wekks

to change the sort order on the resulting table, can be done on the pc with a javascript sort, or on the server by calling the script again with different parameters passed to the sort order

the bees knees of sql
http://dev.mysql.com/doc/refman/5.1/en/

Okay i have been working a little with this code, but i still cant get it to display the wanted information into the table using the included form to select the date range.. pls help my heads getting friendly with my desk....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Helpdesk Statistics</title>
<style type="text/css">
<!--
.style2 {font-size: 36px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>

<body>
<p>&nbsp;</p>
<div align="center">
  <p><img src="images/helpdesk.jpg" width="320" height="75" /></p>
  <p class="style2">STATISTICS</p>
</div>
<div align="center"></div>
<div align="center"></div>
<p align="center"><strong>SELECT DATE RANGE TO SEARCH WITHIN.</strong></p>
<form action="newtest2.php" method="post">
  <div align="center">START DATE:
    <input type="text" name="start" />
    END DATE:
    <input type="text" name="end" />
    <input type="submit" />
  </div>
</form>
<table border="1" align="center">
  <tr>
    <td><div align="center">admin_user</div></td>
    <td><div align="center">update</div></td>
    <td><div align="center">status</div></td>
    <td><div align="center">opened</div></td>
    <td><div align="center">group</div></td>
  </tr>
  <?php do { ?>
  
    <tr>
      <td><div align="center"><?php echo $row_Recordset1['admin_user']; ?></div></td>
      <td><div align="center"><?php echo $row_Recordset1['update']; ?></div></td>
      <td><div align="center"><?php echo $row_Recordset1['status']; ?></div></td>
      <td><div align="center"><?php echo $row_Recordset1['opened']; ?></div></td>
      <td><div align="center"><?php echo $row_Recordset1['group']; ?></div></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

<?php require_once('Connections/helpdesk.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$date1= "$_POST[start]";
$date2= "$_POST[end]"; 
$date1_Recordset1 = "0";
if (isset($date1)) {
  $date1_Recordset1 = $date1;
}
$date2_Recordset1 = "0";
if (isset($date2)) {
  $date2_Recordset1 = $date2;
}
mysql_select_db($database_helpdesk, $helpdesk);
$query_Recordset1 = sprintf("SELECT admin_user, `update`, status, opened, `group` FROM phpdesk_tickets WHERE `opened` >= %s AND `update` <= %s ", GetSQLValueString($date1_Recordset1, "date"),GetSQLValueString($date2_Recordset1, "date"));
$Recordset1 = mysql_query($query_Recordset1, $helpdesk) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.