Witam mam problem nie umiem zrobić odświeżania listy zawodników po dodaniu kordu bad jego aktualizacji.
Samo dodawanie i aktualizacje mam żeby odświeżyć listę to mam problem. Proszę o pomoc.
Lista zawodników z form i dodawanie gracza
<!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="mintAjax.js"></script>
<script type="text/javascript">
function SendRequest(formik)
{
var req = mint.Request();
req.OnAbort = function()
{
alert("Serwer ma problemy z odebraniem zapytania. Spróbuj ponownie późnej.");
}
req.OnLoading = function()
{
$("response").style.display = "block";
$("response").innerHTML = "<img src=\'loader.gif\'>";
}
req.OnSuccess = function(){
$("response").innerHTML = this.responseText;
}
req.SendForm(formik);
}
</script>
<?php
define('DB_HOST','localhost'); require_once('./mysqlclass.php');//Lib od bazy
$db = new sqlcon();//Zalączanie obiektu
add_player($db);
echo '<br /><div id="response"></div><br />'; players_list($db);
function add_player($db)
{
<form id="form_add" method="POST" action="update.php?mode=2">
<tr>
<td>Nr zawodnika:</td>
</tr>
<tr>
<td><input type="text" name="nr" size="5" value="" /></td>
</tr>
<tr>
<td>Imię i Nazwisko:</td>
</tr>
<tr>
<td><input type="text" name="name" size="40" value="" /></td>
</tr>
<tr>
</form>
<td><button onclick="SendRequest(form_add)">Zapisz</button></td>
</tr></table>';
}
function players_list(sqlcon $db)
{
<table><tr><td>Nr</td><td>Imię i Nazwisko</td><td>Akcja</td></tr>';
$query = $db->query("SELECT * FROM players ORDER by nr asc");
while($row = $db->fetch_assoc($query))
{
<form id="form'.$row['id'].'" method="POST" action="update.php?mode=1">
<tr>
<td><input type="text" name="nr" size="5" value="'.$row['nr'].'" /></td>
<input type="hidden" name="id" value="'.$row['id'].'"/>
<td><input type="text" name="name" size="40" value="'.$row['player_name'].'" /></td>
</form><td><button onclick="SendRequest(form'.$row['id'].')">Zapisz</button></td>
</tr>';
}
}<!--c2--></div><!--ec2-->
update.php
<!--c1--><div class='codetop'>Kod</div><div class='codemain'><!--ec1--><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
define('DB_HOST','localhost'); require_once('./mysqlclass.php');//Lib od bazy
$db = new sqlcon();//Zalączanie obiektu
if(!isset($_GET['mode']) OR
(isset($_GET['mode']) && $_GET['mode'] == '1')) {
$mode = "UPDATE players SET";
$mode2 = "WHERE id = '".$_POST['id']."'";
$numer = 'o numerze '.$_POST['nr'].'';
}
elseif(isset($_GET['mode']) && $_GET['mode'] == '2') {
$mode = "INSERT INTO players SET";
$mode2 = "";
$numer = '';
}
if(empty($_POST['name'])) {
echo 'Prosimy podać Imię i Nazwisko zawodnika '.$numer.''; }
elseif(empty($_POST['nr'])) {
echo'Prosimy o podanie numeru zawodnika'; }
else
{
$db->query("".$mode." player_name = '".$_POST['name']."' ,nr = ".intval($_POST['nr'])." ".$mode2." ");
if(!isset($_GET['mode']) OR
(isset($_GET['mode']) && $_GET['mode'] == '1')) {
echo'Zawodnik z numerem '.intval($_POST['nr']).' został uaktualniony'; }
elseif(isset($_GET['mode']) && $_GET['mode'] == '2') {
echo'Zawodnik z numerem '.intval($_POST['nr']).' został dodany'; }
}
?><!--c2--></div><!--ec2-->