Hi all, sorry for my english, I'm Italian :bemused:
I have a table named "Races"
CREATE TABLE `gare` (
`race_id` tinyint(3) NOT NULL default '0',
`pos_gara` tinyint(2) NOT NULL default '0',
`nome_pilota` varchar(50) NOT NULL default '',
`auto` varchar(50) NOT NULL default '',
`giri_gara` tinyint(3) NOT NULL default '0',
`tempo_gara` varchar(20) NOT NULL default '',
`gap_gara` varchar(20) NOT NULL default '',
`fastest_laptime` varchar(20) NOT NULL default '',
`fastest_lapnr` tinyint(3) NOT NULL default '0',
`pos_quali` tinyint(2) NOT NULL default '0',
`tempo_quali` varchar(20) NOT NULL default '',
`gap_quali` varchar(20) NOT NULL default ''
) TYPE=MyISAM;
that is auto-updated with a CSV file (I have excel reports) using this code
<?
// QUESTE RIGHE RENDONO LO SCRIPT COMPATIBILE CON LE VERSIONI
// DI PHP PRECEDENTI ALLA 4.1.0
if(!isset($_FILES)) $_FILES = $HTTP_POST_FILES;
if(!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
/********************* VARIABILI DA SETTARE ********************/
// Directory dove salvare i files Uploadati ( chmod 777, percorso assoluto)
$upload_dir = $_SERVER["DOCUMENT_ROOT"] . "/upload";
// Eventuale nuovo nome da dare al file uploadato
$new_name = "";
//$allowed_types = array("text/csv");
// Se $new_name è vuota, il nome sarà lo stesso del file uploadato
$file_name = ($new_name) ? $new_name : $_FILES["upfile"]["name"];
if(trim($_FILES["upfile"]["name"]) == "") {
die("Non hai indicato il file da uploadare !");
}
//if(@is_uploaded_file($_FILES["upfile"]["tmp_name"])) {
//if(!in_array($_FILES["upfile"]["type"],$allowed_types)) {
//die("Il file non è di un tipo consentito, sono ammessi solo i seguenti: " . implode(",", //$allowed_types) . ".");
//echo "<a href=\"java script:history.go(-1);\">Torna Indietro</a><br>";
//exit;
//}
//}
//e poi qui recuperi il file...elimini tutti i dati dalla tabella
$_DATAFILE=file($_FILES['upfile']['tmp_n
ame']);
include("config.inc.php" );
$db = mysql_connect("$db_host", "$db_user", "$db_password" ) or die("Problem connecting" );
mysql_select_db("$db_name",$db)or die("Problem selecting database" );
while(list($key,$_VALUES)=each($_DATAFIL
E)) {
$_PARAMS=split(";",$_VALUES);
//Qui aggiunge i vari parametri
while (list($key,$value)=each($_PARAMS)) {
$value=str_replace("#","#",$value);
$value=str_replace("--","--",$value);
$value=str_replace("'","'",$value);
$value=str_replace(",",".",$value);
$_PARAMS[$key]=$value;
}
$_querysql="INSERT INTO gare (pos_gara, nome_pilota, auto, giri_gara, tempo_gara, gap_gara, fastest_laptime, fastest_lapnr, pos_quali, tempo_quali, gap_quali) VALUES ('{$_PARAMS[0]}','{$_PARAMS[1]}','{$_PAR
AMS[2]}','{$_PARAMS[3]}','{$_PARAMS[4]}'
,'{$_PARAMS[5]}','{$_PARAMS[6]}','{$_PAR
AMS[7]}','{$_PARAMS[8]}','{$_PARAMS[9]}'
,'{$_PARAMS[10]}')";
if(!mysql_query($_querysql,$db)) {
echo "Errore, modifica dei record non riuscita<BR>";
exit;
} else {
echo "<font color='DARKRED' class='risultatitabebig' face='verdana'>Gara Inserita Nel DB</a></font><BR>";
}
}
echo "<hr>";
?>
now I need to assign to the pos_gara (race position) field the points scored (for example 1st position 20 points, 2nd 15 and so on...)
I can't just have a SUM of the scored points as I would like to have a STANDINGS REPORT where I have all the drivers names and the points scored in every single race and the total
and here I finish my ideas...
which will be the best solution to have points assigned to every single driver for every single race, considering that I do not input datas manually through a form ??
I'm sure there will be different ways to reach the solution BUT ideas just left home....
hope someone will be able to help me
Roberto