I'm having a hard time showing the result of select
the way I want. I will explain first what I have and then what I want, I have two tables in the database:
product_type: product_type_type, product_type and product_mark:
product_id and product_name.
I made select
by joining the two tables to show me the result of the two:
<select name="carne">
<option value="vazio">
</option>
<?php
$sql = "(select tipo_produto from produto_tipo)
union (select nome_marca from produto_marca)";
$result = mysqli_query($conexao, $sql);
while($linha = mysqli_fetch_assoc($result)){ ?>
<option value=" <?php echo $linha['tipo_produto'].$linha['nome_marca']; ?> ">
<?php echo utf8_decode($linha['tipo_produto'].$linha['nome_marca']); ?>
</option>
<?php } ?>
</select>
So far so good, but it is not showing the concatenated result. It's showing like this:
arroz
tio jõao
urbano
I need you to show this:
arroz tio joão
arroz urbano
Since the result of the first part ( arroz
) comes from a table and the result of the second part ( tio joao
) comes from the second table.