I have a little problem with the output of my PHP script.
The purpose of this page is to select one of the ticket status options, such as:
- Open Tickets (display tickets from database with the status "New Tickets" OR "Under Review")
- New Tickets (display tickets from database with the status "New Tickets")
- Under Review (display tickets from database with the status "Under Review")
- Closed Tickets (display tickets from database with the status (Closed Tickets)
After user selects a status, code must display the correct Tickets with chosen status.
So what i tried to do is place a number variable after every option and then try to make it so that when something is selected, refresh the page and send the variable of the option with the page refresh - except that it doesn't work, lol.
I've been brainstorming some time with different ideas to let it check the variable it obtains from selecting a status in the combobox, yet i haven't figured it out which is pretty frustrating.
Important points:
- The script has to work on the same page. Making a new page for every different status is a lot of work and not very efficiënt.
- PHP is the main script language so i prefer the answer in PHP
Here below is the current code:
<?PHP
session_start();
include('connection.php');
if ($_SESSION['staff'] >='6')
{
echo "<select name='type' id='type'>
<option value='Open Tickets'>Open Tickets</option>" . $int= '1' . "
<option value='New Tickets'>New Tickets</option>" . $int= '2' . "
<option value='Under Review'>Under Review</option>" . $int = '3' . "
<option value='Closed Tickets'>Closed Tickets</option>" . $int = '4' . "
</select><BR>";
echo "Current listed support tickets: <BR><BR>";
if ($int = '1')
{
$result1 = mysql_query("SELECT * FROM support WHERE status = 'New Ticket' OR 'Under Review'");
while ($row1 = mysql_fetch_array($result1))
{
$ticket1 = $row1['TicketID'];
$user1 = $row1['name'];
echo "Ticket ID: " . $row1['TicketID'] . "<BR>" . $row1['type'] . "<BR>Subject: " . $row1['subject'] . "<BR>Ticket Status: " . $row1['status'] . "<BR>";
echo "<form action='detail_ticket.php?t=$ticket1' method='post' name='detail_t' id='detail_t'><input type='submit' name='detail_b' id='detail_b' value='View Ticket!'></form>";
echo "<form action='reply_ticket.php?r=$user1' method='post' name='r_ticket' id='r_ticket'><input type='submit' name='reply_b' id='reply_b' value='Reply on Ticket!'></form>";
}
}elseif ($int = '2')
{
$result2 = mysql_query("SELECT * FROM support WHERE status = 'New Ticket'");
while ($row2 = mysql_fetch_array($result2))
{
$ticket2 = $row2['TicketID'];
$user2 = $row2['name'];
echo "Ticket ID: " . $row2['TicketID'] . "<BR>" . $row2['type'] . "<BR>Subject: " . $row2['subject'] . "<BR>Ticket Status: " . $row2['status'] . "<BR>";
echo "<form action='detail_ticket.php?t=$ticket2' method='post' name='detail_t' id='detail_t'><input type='submit' name='detail_b' id='detail_b' value='View Ticket!'></form>";
echo "<form action='reply_ticket.php?r=$user2' method='post' name='r_ticket' id='r_ticket'><input type='submit' name='reply_b' id='reply_b' value='Reply on Ticket!'></form>";
}
}elseif ($int = '3')
{
$result3 = mysql_query("SELECT * FROM support WHERE status = 'New Ticket'");
while ($row3 = mysql_fetch_array($result3))
{
$ticket3 = $row3['TicketID'];
$user3 = $row3['name'];
echo "Ticket ID: " . $row3['TicketID'] . "<BR>" . $row3['type'] . "<BR>Subject: " . $row3['subject'] . "<BR>Ticket Status: " . $row3['status'] . "<BR>";
echo "<form action='detail_ticket.php?t=$ticket3' method='post' name='detail_t' id='detail_t'><input type='submit' name='detail_b' id='detail_b' value='View Ticket!'></form>";
echo "<form action='reply_ticket.php?r=$user3' method='post' name='r_ticket' id='r_ticket'><input type='submit' name='reply_b' id='reply_b' value='Reply on Ticket!'></form>";
}
}elseif ($int = '4')
{
$result4 = mysql_query("SELECT * FROM support WHERE status = 'Closed'");
while ($row4 = mysql_fetch_array($result4))
{
$ticket4 = $row4['TicketID'];
$user4 = $row4['name'];
echo "Ticket ID: " . $row4['TicketID'] . "<BR>" . $row4['type'] . "<BR>Subject: " . $row4['subject'] . "<BR>Ticket Status: " . $row4['status'] . "<BR>";
echo "<form action='detail_ticket.php?t=$ticket4' method='post' name='detail_t' id='detail_t'><input type='submit' name='detail_b' id='detail_b' value='View Ticket!'></form>";
echo "<form action='reply_ticket.php?r=$user4' method='post' name='r_ticket' id='r_ticket'><input type='submit' name='reply_b' id='reply_b' value='Reply on Ticket!'></form>";
}
}
echo "Click <A href='overview_page.php'>HERE</A> to return to the overview page.<BR>";
echo "Click <A href='uitlogen_user.php'>HERE</A> to logout!<BR>";
}else
{
echo "You need to be an GM or Admin to view this page!<BR>";
echo "Click <A href='uitlogen_user.php'>HERE</A> to login!";
}
?>