1
I have the following situation:
When selecting a marca
in tabela
compatibility, I want to list all products in the Product table, whose code is equal to the code of the selected brand.
Example: when selecting Toyota should list Cabin, Lighthouse and Wheel and when selecting Mazda should return only Cabin
I did the following:
$marca = $this->input->post('marca');
$marca = explode(',', $marca);
$query = array();
if (count($marcas) > 0)
{
$i = 0;
foreach ($comp as $row)
{
$i++;
if ($row !== "")
{
if ($row !== "0")
{
$query[] = $row;
$this->db->where_in('marca', $query);
}
}
}
}
But with this code I can only get the products with the following table:
What can I program to make the relation of the two tables through the field codigo
?
and then the solution helped you?
– novic
Good, The solution was very useful, but I could not do what I expected in my script, so I changed the composition of the tables to make my search even easier... instead of using two tables I will use a table... and use the json_decode function
– Gomes