Jump to content

Recommended Posts

Hope this is the right forum

 

I have the following code to show a list of all support tickets by selected category.

 

I get two of every result

Can anyone shed some light on what I am doing wrong?

 

I use pretty much the same code for the user area so they can see their own tickets (Sorted by their user ID and I only get 1 result for that - But in the admin area I am not using the user ID in the query and I get two of everything)

 

<?php	
require_once ('../../mysql_connect.php'); // Connect to the database.

echo '<p>Select a Category to view</p>
<form method="get" action="view_open_support_tickets.php">
<select name="type">
<option value="NULL">Choose a Category:</option>
';

$query = 'SELECT * FROM support_ticket_categories ORDER BY category ASC';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
echo "<option value=\"$row[0]\">$row[1]</option>
";
}

echo '</select>
<input type="submit" name="submit" value="Go!">
</form>

';


if (isset($_GET['type'])) {
$type = (int) $_GET['type'];
} else {
$type = 0;
}

if ($type > 0) {

$query = "SELECT category FROM support_ticket_categories WHERE support_ticket_category_id=$type";
$result = mysql_query ($query);
list ($category) = mysql_fetch_array ($result, MYSQL_NUM);

echo "<hr /><b>$category Tickets</b><br />
<small>(Recently added tickets are listed first.)</small>\n";

$first = TRUE; // Initialize the variable.

$query = "SELECT m.first_name, m.last_name, u.support_ticket_id, status, title FROM users AS m, support_ticket AS u, support_ticket_associations AS ua WHERE u.support_ticket_id = ua.support_ticket_id AND ua.support_ticket_category_id=$type AND ua.approved = 'Y' ORDER BY date_submitted DESC";
$result = mysql_query ($query);

while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {

	// If this is the first record, create the table header.
	if ($first) {
		echo '<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
	<td width="50%"><b>Title</b></td>
	<td width="25%"><b>Status</b></td>	
	<td width="25%"><b>Posted By</b></td>	
</tr>
<tr>
	<td colspan="3"><hr size="1" width="100%"></td>		
</tr>
';
		$first = FALSE; // One record has been returned.
	} // End of $first IF.

	echo "<tr>
		<td><a href=\"respond_support_ticket.php?stid={$row['support_ticket_id']}\">{$row['title']}</a></td>
		<td>{$row['status']}</td>	
		<td>{$row['first_name']} {$row['last_name']}</td>		
	</tr>\n";

} // End of while loop.

// If no records were displayed...
if ($first) {
	echo '<div align="center">There are currently 0 Support Tickets in this category.</div>';
} else {
	echo '</table>'; // Close the table.
}

} // End of $_GET['type'] conditional.

mysql_close(); // Close the database connection.

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.