I'm new here, student of computer science and programming internship ...
I do not know much about how the forum works, but I have a pertinent doubt that I've reviewed Google several times and still can not resolve, even if it's a bit simple =
I have a project to do and I created a table in SQL and I am using PHP, the part of registrations in this tables, listing it and some service call functions work ... however I need to create a button in the list that excludes a line of the table and make the list field editable, but I can not do it at all, would anyone have any tips or guidance?
Thank you !! Here is the code for the listing / change / delete page:
<html>
<head>
<title> MENU DE AÇÔES</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<script src="libs/jquery-3.2.1.min.js"> </script>
<style>
#t{
font-family: arial;
text-align:center;
}
#z{
font-size:105%;
font-weight:bold;
font-style: oblique;
position: relative;
text-align:center;
}
body,
.menu,
.sub-menu {
margin: 0;
padding: 0;
}
.clearfix:after{
content: '';
display: block;
clear: both;
height: 20;
line-height: 0;
font-size: 30;
visibility: hidden;
overflow: hidden;
}
.menu,
.sub-menu {
list-style: none;
background: #000;
}
.sub-menu {
background: #444;
}
.menu a {
text-decoration: none;
display: block;
padding: 20px;
color: #fff;
font-family: sans-serif;
font-size: 18px;
text-transform: uppercase;
font-weight: 700;
}
.menu li {
position: relative;
}
.menu > li {
float: left;
}
.menu > li:hover {
background: #444;
}
.menu li:hover > .sub-menu {
display: block;
}
div{
font-family: arial;
}
</style>
</head>
<body>
<?php include('header.php'); ?>
<form style= "right:2%;left:80%; top:2% ; position:absolute" name="frmBusca" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?a=buscar" >
<input type="text" name="palavra" />
<input type="submit" value="Buscar" />
</form>
<?php
/*
* EXCLUDE FROM WHERE
*
* UPDATE FROM WHERE
*
*
* $_GET
* usar ID para selecionar o elemento
*
*
*/
$acesso = mostra();
function mostra (){
$palavra = $_POST['palavra'];
$servidor = "localhost";
$usuario = "root";
$senha = "asdf000";
$banco = "automoveis";
$conexao = mysqli_connect($servidor,$usuario,$senha, $banco);
if($conexao){
$db=mysqli_select_db($conexao, $banco);
} else {
echo ("Erro ao conectar ao bando de dados");
return false;
}
$String = "SELECT descricao,placa,codigoRenavam,anoModelo,anoFabricacao,cor,km,marca,preco,preco Fipe FROM automovel ";
if($palavra != ''){
$String .= "WHERE descricao LIKE '%".$palavra."%' OR placa LIKE '%".$palavra."%' OR codigoRenavam LIKE '%".$palavra."%' OR anoModelo LIKE '%".$palavra."%' OR anoFabricacao LIKE '%".$palavra."%'
OR cor LIKE '%".$palavra."%' OR km LIKE '%".$palavra."%' OR marca LIKE ' %".$palavra."%' OR preco LIKE '%".$palavra."%' OR precoFipe LIKE '%".$palavra."%' ";
}
$String .= "ORDER BY descricao ";
$sql = mysqli_query($conexao, $String);
echo '<table border = 10 bordercolor = "#000" cellpadding="25" width="100%" table style="table-layout: fixed ;">';
echo '<tr id = "z"><td> Descrição </td><td> Placa </td><td>RENAVAM</td><td>Ano do Modelo</td><td> Ano de Fabricação</td><td> Cor</td>
<td> Kilometragem </td> <td> Marca</td> <td> Preço </td> <td> Preço FIPE </td> <td> Exclui </td></tr>';
while( $exibe = mysqli_fetch_assoc($sql)){
echo "<h3> <tr > <td>" .$exibe['descricao']. "</td> ";
echo " <td>" .$exibe['placa']. "</td> ";
echo " <td>" .$exibe['codigoRenavam']. "</td> ";
echo " <td>" .$exibe['anoModelo']. "</td> ";
echo " <td>" .$exibe['anoFabricacao']. "</td> ";
echo " <td>" .$exibe['cor']. "</td> ";
echo " <td>" .$exibe['km']. "</td> ";
echo " <td>" .$exibe['marca']. "</td> ";
echo " <td>" .$exibe['preco']. "</td> ";
echo " <td>" .$exibe['precoFipe']. "</td>";
echo"<td> </td>";"</tr><h3>";
}
echo '</table>';
}
?>
</body>
</html>