0
My form has the option to add more rows, so I had to use array and send its information to the database. In this case the database has created 3 rows within the table with various information, but the name (column in specific) has the same information in the three, and at the time of calling for html I would like to call only once this name that repeats 3 times.
connection to db:
<?php
require_once('db_connect.php');
for( $i=0; $i<count($_POST['exercicio']); $i++ ) {
// INSERINDO NO MYSQL
$sql = "INSERT INTO ficha
(nomeFicha,
nomeExercicio,
grupoMuscular,
numSeries,
numRepeticoes,
peso
)
VALUES
(
'".$_POST['nomeFicha']."',
'".$_POST['exercicio'][$i]."',
'".$_POST['grupoMusc'][$i]."',
'".$_POST['numSeries'][$i]."',
'".$_POST['numRep'][$i]."',
'".$_POST['peso'][$i]."'
)";
echo $sql;
$queryExec = mysqli_query($connect, $sql) or die('ERRO ao inserir registro no Banco');
}
if ( $queryExec) {
header('location: ../fichas.php?sucesso');
} else {
header('location: ../fichas.php?erro');
}
html:
<div id="divContent" class="container-fluid">
<ul id="lista" class="list-group">
<?php
$sql ="SELECT nomeFicha FROM ficha";
$resultado = mysqli_query($connect, $sql);
while($dados = mysqli_fetch_array($resultado)):
?>
<li class="list-group-item"><?php echo $dados['nomeFicha']; ?></li>
<?php endwhile; ?>
</ul>
I had already managed to find the answer but vlw was this msm that I wanted. I’ll look at the link that you sent.
– Lucas Kohler
@Lucaskohler be careful with this reference. w3schools is not reliable.
– Jorge B.