3
I’m having a little difficulty with the INNER JOIN query. I have a table called users and it contains the following fields:
First Name
Last Name
Tipo_fk (Foreing Key)
Categoria_fk (Foreing Key)
As shown above the HTML select function works fine but when I load my table to show the registered data, the fields "Type" and "Category" show the ID number of the selected value in the combobox instead of the selected name.
Below follows the query (INNER JOIN) I am using to try to display the name instead of the ID number of the selected item.
SELECT users.*, tipo_ps.tipo_id , categorias.categoria_id
FROM ((users
INNER JOIN categorias ON users.categoria_fk = categorias.categoria_id)
INNER JOIN tipo_ps ON users.tipo_fk = tipo_ps.tipo_id)
And an excerpt from the table in which I mentioned that shows only the ID number of the value selected in the droplist after registration:
Instead of the id
das
categoriese
type_ps` intends to show what exactly?– João Martins
In this field you are presenting the type ID and category ID. See which fields your query returns, and then change in html instead of showing Ids, switch to the fields you want.
– Luís Almeida
Hello John and Louis. Thank you for the return. So, what I intend is that when filling out a form and saving it later using the (Insert into), these data would be saved and shown in a table. In this case I can do this but in the table is shown the ID number of the value contained in the droplist instead of the name itself. In the field (type_ps) I have: (ID 1) -> Product and (ID 2) -> Service and in the field (categoria_fk) I have (ID 1) -> Metals, (ID 2) -> Consulting and (ID 3) -> Electronics.
– Michel
In html I am using: <select name="typo_fk" class="form-control"> <?php foreach($Results as $Row): ? > <option value="<?= $Row['typo_id']; ? >"><?= $Row['type']; ? ></option> <? php endforeach ? > </select>
– Michel