0
I am not able to take the data from the unit table and put it in a combobox. The combobox does not work and appears to subanswer. I have a table called "tblutentes" with the name of the user and then I have a table called unit with the names of the units. Wanted a combobox that received the name of the drive that is saved in mysql.
here I have the introductory code:
<?php
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['alogin'])==0)
{
header('location:index.php');
}
else{
if(isset($_POST['add']))
{
$nomeutente=$_POST['NomeUtente'];
$sql="INSERT INTO tblutentes(NomeUtente) VALUES(:nomeutente)";
$query = $dbh->prepare($sql);
$query->bindParam(':nomeutente',$nomeutente,PDO::PARAM_STR);
$lastInsertId = $dbh->lastInsertId();
$query->execute();
if($lastInsertId)
{
$msg="Utente Adicionado Com Sucesso!";
}
else
{
$error="Erro, tente novamente!";
}}
?>
And here’s the combobox part:
<div class="row">
<form class="col s12" method="POST">
<div class="input-field">
<?php if($error){?><div class="errorWrap"><strong>ERROR</strong>:<?php echo htmlentities($error); ?> </div><?php }
else if($msg){?><div class="succWrap"><strong>SUCESSO</strong>:<?php echo htmlentities($msg); ?> </div><?php }?>
<form name="unidade" method="POST" action="">
<label for="">Selecione a unidade</label>
<select>
<option>Selecione...</option>
<?php while($prod = mysql_fetch_array($query)) { ?>
<option value="<?php echo $prod['UniID'] ?>"><?php echo $prod['TipoUnidade'] ?></option>
<?php } ?>
</select>
</form>
<div class="input-field col s6">
<i class="material-icons prefix">account_circle</i>
<input id = "NomeUtente" type = "text" class = "validate" name = "NomeUtente" required>
<label for="nomeutente" class="active">Nome Utente</label>
</div>
<button class="btn #ff7043 deep-orange lighten-1 right" type="submit" name="add">Adicionar
<i class="material-icons right">send</i>
</button>
</div>
</form>
</div>
Thank you so much for the help, I’m using materialize
– fff
@If I’m not mistaken, the materialize also uses a system similar to "Rows" and "cols" (https://materializecss.com/grid.html). You still got the problem?
– ThiagoYou
thanks a lot for the help, but really as it was giving so much trouble I gave up doing this way
– fff