Uff.... non funziona...
Ho modificato il codice come mi avevi detto, ma non va...
Riporto di seguito il codice completo:
Codice PHP:
<form name="chartform" method="post" action="">
<label>Nome:
<input name="nome" type="text" />
</label>
<label>Cognome:
<input name="cognome" type="text" />
</label>
<input name="aggiungi" type="submit" value="Aggiungi" />
</form>
<?php
if($_POST){
addplayer();
}
function addplayer()
{
require 'dbconnect/config.php';
require 'dbconnect/connect.php';
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
$query="INSERT INTO chart(nome,cognome,punti) VALUES ('$nome','$cognome','0')";
$result = mysql_query($query);
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
mysql_close();
}
?>
<?php
require 'dbconnect/config.php';
require 'dbconnect/connect.php';
echo 'Giocatori
';
$player = mysql_query("SELECT id, nome, cognome, punti FROM chart ");
while ($row = mysql_fetch_row($player)) {
echo '<div style="width:30px;height:20px;float:left;">',
$row[0] ,
'</div><div style="width:100px;height:20px;float:left;">',
$row[1] ,
'</div><div style="width:100px;height:20px;float:left;">',
$row[2],
'</div><div style="width:30px;height:20px;float:left;">',
$row[3],
'</div><div style="height:20px;float:left;">',
'<input name="score" type="text" size="2" maxlength="3" />',
'</div>
';
echo '[url="index.php?do=delete&id=1"]Cancellami[/url]';
}
if($_GET['do'] == "delete" && !empty($_GET['id'])){
$id = intval($_GET['id']);
deleteplayer($id);
}
function deleteplayer($id){
$result = mysql_query("DELETE FROM chart WHERE id = $id");
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
}
?>