1
How to compare the Array
of explode
, with the text of option
. If the same, mark with Selected.
<?php
//header('Content-Type: application/json; charset=utf-8');
include 'config.php';
$rs2 = $conexao->query("SELECT * FROM tags WHERE id_subcategoria = '{$_GET['id']}' AND idioma = 'pt-br' ");
$rs3 = $conexao->query("SELECT habilidades FROM categoriasub WHERE ID_Subcategoria = '{$_GET['id']}' AND idioma = 'pt-br' ");
$row3 = $rs3->fetch_assoc();
$habilidades = explode(",", $row3['habilidades']);
while($row2 = $rs2->fetch_assoc()) {
echo '<option value="'.$row2['ID_Tag'].'">'.$row2['tag'].'</option>';
}
?>
While result
<option value="1">PHP</option>
<option value="2">MYSQL</option>
<option value="3">HTML</option>
<option value="4">Designer de site</option>
Array result $skills
Array
(
[0] => PHP
[1] => HTML
[2] => Designer de site
)
In this case would be 3 options selected? You are using
multiple
in theselect
of HTML?– Woss
@Andersoncarloswoss Exactly. Yes I’m using the
multiple
.– Tiago