Witam! Mam taki kod jak poniżej. Generuje on tabelę html i wyświetla w niej konkretne rekordy z bazy danych. Jednak gdy chcę te tabelę posortować np po nazwie użytkownika, posortowane rekordy zostają do tej tabeli dopisane zamiast zastapić poprzednie. Jak to naprawić?
<table name="table" border="1" style="color:1c4e93;">
<thead>
<tr><!--<form method = "post" >-->
<th class = "th"><input type="hidden" name="id" value="id" /><input type="submit" value="ID" name="id_user" class="btn btn-default btn-success"></th>
<th class = "th"><input type="hidden" name="username" value="username" /><input type="button" value="Login" name="uname" class="btn btn-default btn-success" style="width: 222px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/users_sort.php?param=username'"></th>
<th class = "th"><input type="hidden" name="password" value="password" /><input type="submit" value="Hasło" name="upass" class="btn btn-default btn-success" style="width: 222px;"></th>
<th class = "th"><input type="hidden" name="lname" value="lname" /><input type="submit" value="Nazwisko" name="ulname" class="btn btn-default btn-success" style="width: 222px;"></th>
<th class = "th"><input type="hidden" name="surname" value="surname" /><input type="submit" value="Imię" name="ufname" class="btn btn-default btn-success" style="width: 222px;"></th>
<th class = "th"><input type="hidden" name="email" value="email" /><input type="submit" value="Email" name="umail" class="btn btn-default btn-success" style="width: 222px;"></th>
<th class = "th" width="120px;"><div style = "width: 120px;">Opcje</div></th>
</tr>
</thead>
<tbody>
<tr>
<?php
function show($query_disp){
include ('/var/www/vhosts/solaris-ustronie.eu/httpdocs/joomla/administrator/modules/mod_activate/db_joomla.php');
$resultSet = mysql_query($query_disp, $con);
$table ="jos_users";
$id_col="id";
//ini_set('max_execution_time', 300);
while($row = mysql_fetch_array($resultSet)) {
$id= $row['id'];
$name= $row['username'];
$pass=$row['password'];
$llname =$row['name'];
$ffname=$row['surname'];
$mail = $row['email'];
?>
<form id="form_users" action = "https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/edit_user.php" method = "GET"><p>
<td class="container" width = "40px;"><center><?php echo $row['id'];?></td>
<td class="container" ><div><input type="text" name="name" size="40;" line-height="0px" value="<?php echo $row['username'];?>"></input></div></td>
<td class="container"><div class="td_div"><input type="text" name="pass" size="40" line-height="0px" value="<?php echo $row['password'];?>"></input></div></td>
<td class="container"><div><input type="text" name="llname" size="40" line-height="0px" value="<?php echo $row['name'];?>"></input></div></td>
<td class="container"><div><input type="text" name="ffname" size="40" line-height="0px" value="<?php echo $row['surname'];?>"></input></div></td>
<td class="container"><div><input type="text" name="mail" size="40" line-height="0px" value="<?php echo $row['email'];?>"></input></div></td>
<td class="container">
<div> <input type="hidden" name="id" value="<?php echo $id; ?> " /><div>
<div><input type="hidden" name="table" value="<?php echo $table; ?> " /></div>
<div><div class="opt_btn" ><input type="submit" value="Zapisz" class="btn btn-default btn-success"></div></form></p><div class="opt_btnu"> <input type="button" value="Usuń" class="btn btn-primary" style="width: 58px;" onClick="location.href='https://www.solaris-ustronie.eu/joomla/administrator/modules/mod_activate/delete.php?param=<?php echo $table;?>,<?php echo $id_col;?>,<?php echo $id;?>'"></div></div>
</td>
</tr>
<?php } mysql_close();}
show($query_disp);
if(isset ($_GET['query']))
{
$query=$_GET['query'];
$query0="SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent'";
$query1 = "SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent' ORDER BY id ASC";
$query2 = "SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent' ORDER BY username ASC";
$query3 = "SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent' ORDER BY name ASC";
$query4 = "SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent' ORDER BY surname ASC ";
$query5 = "SELECT * FROM jos_users WHERE program_user = '1' AND parent = '$parent' ORDER BY email ASC ";
if($query=='query1' )
{
$query_disp=$query1;
}
if($query=='query2'){
$query_disp=$query2;
parent.window.location.reload();
show($query_disp);
}
if($query=='query3'){
$query_disp=$query3;
}
if($query=='query4'){
$query_disp=$query4;
}
if($query=='query5'){
$query_disp=$query5;
}
else
{
$query_disp=$query0;
}
$error= $query_disp;
} ?>
</tbody>
</table>