function connectDB(){
$conexion = mysqli_connect("servidor", "usuario", "contraseña", "base de datos");
if($conexion){
echo 'La conexión de la base de datos se ha hecho satisfactoriamente
';
}else{
echo 'Ha sucedido un error inesperado en la conexión de la base de datos
';
}
return $conexion;
}
It is my base code to make the connection to the database.
Although, I do not know exactly how to do to select the table from where the data will be obtained.
I have this one that I used in a separate project, but I do not know if it is valid for what I want to do, since I still do not understand very well how to do it, therefore I have not done tests:
$nick = urlencode($_GET['nick']);
mysql_select_db("statistiques", $link);
$result = mysql_query("SELECT * FROM player WHERE name='".$nick."'", $link);
What I want to do is summarized more or less in these tutorials:
Creating a JSON from of a query in MySQL.
But I still do not know how to do all that and I do not understand the tutorial very well.
Within the table statistiques
, there is another call player
. Whose data I want to set so that others can do queries from my file are :
id, name, title, experience, first, bootcamp, round_played, shaman_cheese, saved_mice, saved_mice_hard, saved_mice_divine, cheese_gathered
.