i'm creating a support ticket system, and now i'm wondering about something, i can't figure out how to make reply system on each ticket. The problem is i don't know how to store replies and load them for each ticket. For example if ticket is like dashboard.php?id=3 to load me only replies from that ticked ID if it has questions in it and like that for other tickets, this is the code i have at the moment:
// this is loading of all user tickets
if (!isset($_GET['action']))
{
echo "
</br><div class='dashboard_info'>Dobrodosli, ovo je vas dashboard. Njegova svrha je pomaganje novim clanovima nase zajednice ali i starijima koji
imaju poteskoce u snalazenju sa radom User Control Panela. Koriscenjem istog imate razne opcije, ali glavna svrha ovog dela jeste resavanje raznih problema otvaranjem tiketa i slanjem upita.
Ispod mozete videti vase aktivne tikete ukoliko imate istih, ukoliko vam treba pomoc oko necega mozete poslati tiket klikom na Novi Tiket.</div>
</br></br></br><center>
<div class='dataTables'>
<table>
<tr>
<td CLASS='MYTABLE'>Naslov Tiketa</td>
<td CLASS='MYTABLE'>#ID Tiketa</td>
<td CLASS='MYTABLE'>Status Tiketa</td>
<td CLASS='MYTABLE'>Vrsta Tiketa</td>
<td CLASS='MYTABLE'>Datum</td>
</tr>
</center>
";
$username = $_COOKIE['username'];
$author = mysqli_real_escape_string($con, $username);
$query = "SELECT * FROM Dashboard WHERE Postavio = '$author'";
$result = mysqli_query($con,$query);
while( $row = mysqli_fetch_array($result,MYSQLI_ASSOC) )
{
$ID = clear($row['ID']);
$Naslov = clear($row['Naslov']);
$Status = clear($row['Status']);
$Vrsta = clear($row['Vrsta']);
$Datum = clear($row['Datum']);
if($Status == 0) { $statusinfo = "Otvoren"; }
else if($Status == 1) { $statusinfo = "Zatvoren"; }
else if($Status == 2) { $statusinfo = "Odgovoren"; }
echo "
<tr CLASS='MYTABLE'>
<td CLASS='MYTABLE'><a href='dashboard.php?id=$ID'>$Naslov</a></td>
<td CLASS='MYTABLE'><a href='dashboard.php?id=$ID'>#0000$ID</a></td>
<td CLASS='MYTABLE'>$statusinfo</td>
<td CLASS='MYTABLE'>$Vrsta</td>
<td CLASS='MYTABLE'>$Datum</td>
<tr>
";
}
}
// this is loading of page with id
if(isset($_GET['id']))
{
$id = clear($_GET['id']);
$user = mysqli_real_escape_string($con, $_COOKIE['username']);
$query = "SELECT * FROM `dashboard` WHERE `Postavio` = '$username' AND `ID` = '$id'";
mysqli_query($con, $query);
$output = mysqli_num_rows($result);
if($output == 0)
{
echo "Vi ste vlasnik ovog ticketa";
exit();
}
else
{
echo "Vi niste vlasnik ovog ticketa";
}
}
but this doesnt work well even, it should get id from url and compare it to one in database and see if it's made by the user, and if its made by someone else than it should return him to main page.