My problem is that I want to create several elements according to the amount that the While syllabus finds and assign the counter concatenated with the name of the CLASS that already has (THAT IS: ELEMENT); also assign the counter as an identifier; AS YOU CAN SEE IN THE OTHER CODE THAT WILL SEND THEM, I WILL GIVE YOU THE NAME TO THE DOCUMENT MADE IN HTML
This in the Code I Want to Resolve Using Jquery Php and Mysql
#campoBusq {
border: 1px solid blue ;
width:45%;
float:left;
padding:5px;
height:300px;
}
#categoria {
border: 1px solid red;
width:45%;
padding:5px;
float:left;
height:300px;
}
.elemento {
border: 1px solid green;
width:90%;
margin:1%;
padding:1%;
float:left;
clear:left;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="campoBusq"></div>
<div id="categoria">
<?php
include('../configuracion/conexion.php');
?>
<script>
<?php
$consulta = "SELECT idCategoria FROM buscar_categoria";
$resultado = $conexion->query($consulta) or die("Error de busqueda o conexion");
while ($datosCateorias=$resultado->fetch_assoc() ) {
?>
var datosCateorias = '<?php echo $datosCateorias['idCategoria'] ?>';
$('#categoria').append('<option class="elemento '+contador+'" ident="'+contador+'" >' + datosCateorias + '</option>');
<?php
}
mysqli_free_result($resultado);
$conexion->close();
?>
</script>
</div>
</div>
The script gives me this message WHERE THE VALUES ARE NOT PRINTED