Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ángel Chica Moral
/
tbw2122_4
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fbad555c
authored
Mar 21, 2022
by
Javier Godino Moral
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Inserccion datos equipos a BD
parent
81bb332f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
12 deletions
administrador/config/bd.php
administrador/seccion/equipos.php
administrador/config/bd.php
View file @
fbad555c
...
...
@@ -7,7 +7,7 @@
try
{
$conexion
=
new
PDO
(
"mysql:host=
$host
;dbname=
$bd
"
,
$usuario
,
$contrasenia
);
if
(
$conexion
){
echo
"Conectado al sistema"
;}
}
catch
(
Exception
$ex
)
{
echo
$ex
->
getMessage
();
...
...
administrador/seccion/equipos.php
View file @
fbad555c
<?php
include
(
"../template/cabecera.php"
);
?>
<?php
print_r
(
$_POST
);
$txtequipo
=
(
isset
(
$_POST
[
'id_equipo'
]))
?
$_POST
[
'id_equipo'
]
:
""
;
$txtnombreEquipo
=
(
isset
(
$_POST
[
'nombreEquipo'
]))
?
$_POST
[
'nombreEquipo'
]
:
""
;
$txtimagen
=
(
isset
(
$_FILES
[
'imgEquipo'
][
'name'
]))
?
$_FILES
[
'imgEquipo'
][
'name'
]
:
""
;
...
...
@@ -14,7 +13,9 @@
switch
(
$accion
){
case
"Agregar"
:
//INSERT INTO `equipos` (`id`, `Nombre`, `Imagen`) VALUES (NULL, 'atlethic', 'atlethic.png');
$SQL
=
$conexion
->
prepare
(
"INSERT INTO `equipos` (`id`, `Nombre`, `Imagen`) VALUES (NULL, 'atlethic', 'atlethic.png');"
);
$SQL
=
$conexion
->
prepare
(
"INSERT INTO equipos ( Nombre, Imagen) VALUES (:nombre, :escudo);"
);
$SQL
->
bindParam
(
':nombre'
,
$txtnombreEquipo
);
$SQL
->
bindParam
(
':escudo'
,
$txtimagen
);
$SQL
->
execute
();
...
...
@@ -23,9 +24,26 @@
break
;
case
"Cancelar"
:
break
;
case
"Seleccionar"
:
$SQL
=
$conexion
->
prepare
(
"SELECT * FROM equipos WHERE id=:id"
);
$SQL
->
bindParam
(
':id'
,
$txtequipo
);
$SQL
->
execute
();
$Equipo
=
$SQL
->
fetch
(
PDO
::
FETCH_LAZY
);
$txtnombreEquipo
=
$Equipo
[
'Nombre'
];
$txtimagen
=
$Equipo
[
'Imagen'
];
break
;
case
"Borrar"
:
$SQL
=
$conexion
->
prepare
(
"DELETE FROM equipos WHERE id=:id"
);
$SQL
->
bindParam
(
':id'
,
$txtequipo
);
$SQL
->
execute
();
break
;
}
$SQL
=
$conexion
->
prepare
(
"SELECT * FROM equipos"
);
$SQL
->
execute
();
$listaEquipos
=
$SQL
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
?>
...
...
@@ -40,17 +58,17 @@
<div
class =
"form-group"
>
<label
for=
"id_equipo"
>
ID Equipo:
</label>
<input
type=
"text"
class=
"form-control"
name=
"id_equipo"
id=
"id_equipo"
placeholder=
"Indica el id del nuevo equipo"
>
<input
type=
"text"
class=
"form-control"
value=
"
<?php
echo
$txtequipo
;
?>
"
name=
"id_equipo"
id=
"id_equipo"
placeholder=
"Indica el id del nuevo equipo"
>
</div>
<div
class =
"form-group"
>
<label
for=
"nombreEquipo"
>
Nombre:
</label>
<input
type=
"text"
class=
"form-control"
name=
"nombreEquipo"
id=
"nombreEquipo"
placeholder=
"Añade un equipo"
>
<input
type=
"text"
class=
"form-control"
value=
"
<?php
echo
$txtnombreEquipo
;
?>
"
name=
"nombreEquipo"
id=
"nombreEquipo"
placeholder=
"Añade un equipo"
>
</div>
<div
class =
"form-group"
>
<label
for=
"imgEquipo"
>
Escudo:
</label>
<input
type=
"file"
class=
"form-control"
name=
"imgEquipo"
id=
"imgEquipo"
placeholder=
"Añade un escudo"
>
<label
for=
"imgEquipo"
>
Escudo:
<
?php
echo
$txtimagen
;
?>
<
/label>
<input
type=
"file"
class=
"form-control"
name=
"imgEquipo"
id=
"imgEquipo"
placeholder=
"Añade un escudo"
>
</div>
<div
class=
"btn-group"
role=
"group"
aria-label=
""
>
...
...
@@ -70,21 +88,32 @@
<table
class=
"table table-bordered"
>
<thead>
<tr>
<th>
ID Equipo
</th>
<th>
Equipo
</th>
<th>
Jugador
</th>
<th>
Escudo
</th>
<th>
Tarjetas
</th>
<th>
Goles
</th>
<th>
Acciones
</th>
</tr>
</thead>
<tbody>
<?php
foreach
(
$listaEquipos
as
$equipo
)
{
?>
<tr>
<td>
Nombre equipo
</td>
<td>
Nombre jugador
</td>
<td>
<?php
echo
$equipo
[
'id'
]
?>
</td>
<td>
<?php
echo
$equipo
[
'Nombre'
]
?>
</td>
<td>
<?php
echo
$equipo
[
'Imagen'
]
?>
</td>
<td>
Goles
</td>
<td>
Tarjetas
</td>
<td>
Seleccionar | Borrar
</td>
<td>
<form
method=
"POST"
>
<input
type=
"hidden"
name=
"id_equipo"
id=
"id_equipo"
value=
"
<?php
echo
$equipo
[
'id'
]
?>
"
/>
<input
type=
"submit"
name=
"accion"
value=
"Seleccionar"
class=
"btn btn-primary"
/>
<input
type=
"submit"
name=
"accion"
value=
"Borrar"
class=
"btn btn-danger"
/>
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment