I am working on a Help Desk Ticketing system and have a page called MY TICKETS which shows all tickets in grids. the problem is that the number of records are around 30 to 40 but there is a lag around more then 10 seconds while populating the grid. I think its the way I've written. So I need suggestion to improve or correct my problems if any. Please help..here is the code
MyTickets.php
Code: <?php
session_start();
if (!isset($_SESSION['uid']))
{
header('location: login.php');
}
?>
<!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>CRPL Support - My Tickets</title>
<link rel="stylesheet" href="css/eticket.css" media="screen">
</head>
<!--<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" /> -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<!--<script type="text/javascript" src="js/supportvalidations.js"></script> -->
<script type="text/javascript" src="js/testajax.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CRPL Support System</title>
</head>
<body>
<div class="container">
<h1><img src="images/logosupport.gif" alt="crplTicket" width="222" height="59" border="0"></h1>
<div class="nav">
<ul>
<li>
</li>
<li id="home"><a href="newticket.php"><img src="images/home.gif" border="0" alt="Main" />New Ticket </a></li>
<li id="mytickets"><a href="mytickets.php"><img src="images/my_tickets.gif" border="0" alt="Main" /> My Tickets</a></li>
</ul>
</div>
<div class="content">
<center> </center>
<div style="margin: 10px 0 60px 0;">
<table width="100%" border="0" cellspacing=0 cellpadding=0 align="center">
<tr>
<td nowrap >
<a href="javascript:filterOpen()"><img src="images/view_open_btn.gif" alt="View Open" border=0></a>
<a href="javascript:filterClosed()"><img src="images/view_closed_btn.gif" alt="View Closed" border=0></a> <a href="javascript:nofilter()"><img src="images/refresh_btn.gif" alt="Refresh" border=0></a>
</td>
</tr>
</table>
<div id="grid_data">
</div>
<div style="clear:both"></div>
</div>
<div class="pre-footer"><br />
<br />
<br />
Support Ticket S</div>
<div class="footer"><table border="0" width="100%">
<tr>
<td><a href="http://www.cr-pl.com" target="_blank">Powered by CRPL</a>
<form id="form1" name="form1" method="post" action="">
<input type="hidden" name="vtype" id="vtype" value="G"/>
<?php session_start();
$mycus_idx = $_SESSION["uid"];
?>
<input type="hidden" name="mycusid" id="mycusid" value=<?php echo $mycus_idx ?> >
</form></td>
<td align="right"> </td></tr>
</table></div>
</div>
</div>
<br/>
<script>
//call after page loaded
window.onload=defaultgrid;
</script>
</body>
</html>
As you can see at the bottom I've used a javascript which triggers at the end of the page..
defaultgrid javascript
-----------------------------
Code: function defaultgrid()
{
var dataString = "mycusid="+document.getElementById('mycusid').value+"&dtype="+document.getElementById('vtype').value+"&sid="+Math.random();
$.ajax({
type: "GET", //GET Method used instead of POST
url: "buildgrid.php", //php file that processes the data
data: dataString, //Pass the data
cache: false, //Do not cache the page
success: function(returnString)
{
document.getElementById('grid_data').innerHTML = returnString;
}
});
}
Finally the code which actually populates the grid...
---------------------
buildgrid.php
---------------------
Code: <?php
require_once('hostinfo.php');
// Connect to server and select databse.
$connection = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error : Cannot connect to the database..");
mysql_select_db($dbname) or die("Error : Cannot select Database...");
//Display type
$vtype = $_GET['dtype'];
$pcusid = $_GET['mycusid'];
if($vtype == 'G')
{
//Default query
$squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' order by ticketdate desc";
}
if($vtype == 'O')
{
//Default query
$squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' AND status='O' order by ticketdate desc";
}
if($vtype == 'C')
{
//Default query
$squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' AND status='C' order by ticketdate desc";
}
if($vtype == 'D')
{
//Default query
$squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' and department='S' order by ticketdate desc";
}
//Execute Statement using mySQL database
$result = mysql_query($squery, $connection) or die(mysql_error());
$ticketRS = mysql_fetch_assoc($result);
if($ticketRS["ticketno"] == "")
{
echo "<br/><br/> No ticket found ...";
return;
}
echo "<table width='100%' border='0' cellspacing=0 cellpadding=2>";
echo "<tr>";
echo "<td>";
echo "<table border='0' cellspacing=0 cellpadding=2 class='tgrid' align='center'>";
echo "<tr>";
echo "<th width='105' height='20' nowrap>";
// echo "<a href='view.php?sort=ID&order=ASC&' title='Sort By Ticket ID ASC'>Ticket #</a></th>";
echo "Ticket #</th>";
echo "<th width='100'>";
// echo "<a href='view.php?sort=date&order=ASC&' title='Sort By Date ASC'>Creation Date</a></th>";
echo "Creation Date</th>";
echo "<th width='60' align='center'>Status</th>";
echo "<th width='240'>Subject</th>";
echo "<th width='150' align='center'>";
// echo "<a href='view.php?sort=dept&order=ASC&' title='Sort By Category ASC'>Department</a></th>";
echo "Department</th>";
echo "<th width='150'>Priority</th>";
echo "<th width='150'>City</th>";
do
{
$theticket = "'" .$ticketRS["ticketno"] . "'";
echo "<tr class='row1' id='496115'>";
echo "<td align='center' title='" .$ticketRS["ticketno"]. "' nowrap>";
// echo "<a class='Icon webTicket' href=javascript:viewticket(" .$ticketRS["ticketno"]. ",'Grid')>" .$ticketRS["ticketno"]."</a></td>";
echo "<a class='Icon webTicket' href=javascript:viewticket(" .$theticket. ",'Grid')>" .$ticketRS["ticketno"]."</a></td>";
// echo "<a class='Icon webTicket' href='javascript:zahid()'>" .$ticketRS["ticketno"]."</a></td>";
echo "<td nowrap> " .$ticketRS["ticketdate"]. "</td>";
echo "<td> " ;
if($ticketRS["status"] == "O")
{
echo "Open" ;
} else
echo "Close";
echo " </td>";
echo "<td> " .$ticketRS["subject"] . " </td>";
echo "<td align='center'> ";
if($ticketRS["department"] == 'H')
{
echo "Hardware" ;
}else
echo "Software"; echo " </td>";
echo "<td align='center'>";
if($ticketRS["priority"] == 'H') echo "High" ; if($ticketRS["priority"] == 'N') echo "Normal" ;
if($ticketRS["priority"] == 'L') echo "Low" ; echo "</td>";
echo "<td align='center'>" .$ticketRS["city"] . "</td>";
echo "</tr>";
} while ($ticketRS = mysql_fetch_assoc($result));
echo "</table> </td> </tr> <tr> <td> </table>";
?>
Problems with array
This code is the last lines in an upload script that uploads 4 images at the same time and writes the url to these and som other information to the database. database structure: id img1 img2 img3
Calling variables
I want to call this to my website but it doesn't display what I want it to,Code: <h5>Edit Subject: <?php echo $sel_subject['menu_name']; ?></h5>If I change
ereg_replace()
Basically what i need to do is $title = "This Suck's"$striped = ereg_replace("[^A-Za-z0-9]", " ", $title ); However, I only want it to strip the " ' "
Anti Spam Code
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I have been working on this problem for 3 days and have had no luck!Here we go:I have a rate and
need help in mysql_num_rows()
please tell me what i am doing wrong in this query. it displays this errorCode: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wamp\www\dynamic\quiz2.php on
Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to connect but it reports back this error:QuoteWarning: mysql_query(): 11 is not a valid MySQL-Link resource
help with email script...
hey I need help with my mail scriptwhen the form on http://www.mcgdesignstudio.com/contact.html is filled out, it send the from with no errors.. however i never receive it.. my hosting company have
Limiting checkboxes?
Hi guys, I have this code: Code: if(isset($_POST['selected'])) { foreach($_POST['selected'] as $item) { $sql = "SELECT * FROM tablename WHERE ID=$item"; mysql_query($sql) or
php/mysql auto logout after 2 hour and reset password
Hi all, This I hope will make sense. I've the following code which when a user logins in, creates a session: if (isset($_POST['submitted'])) { // Check if the form has been submitted. require_once
Variable passed to each() is not an array or object
Hi,This is a email a friend type of form, and it isn't working anymore.<? function validate_email($email, $location) { $valid_address = true; $mail_pat = '^(.+)@(.+)$'; $valid_chars =