Answer the question
In order to leave comments, you need to log in
How to compose an SQL query?
Hello everyone, friends, in general, it happens when you need to display items in a list like this
[item]
[item]
[item] [item] [item]
[item]
[item]
Do you understand the meaning? And where there is an output + two more additional [item] There should be a connection from the leftmost [item]. For example by id This is something like a subdirectory:
a single instance
of an instance, another instance associated with it.
the only copy
I keep trying to explain the problem. There are two tables where one records of the main elements are stored. And there is another table that has a connection with them by id, where the subelements of these elements are stored.
So you think, pfft problem. Let's make a mixed request, and to hell with it. Yes, we get what we wanted, but not what we need.
In the display, just the same, you need to display this kind of
[item]
[item]
[item] [item] [item]
[item]
[item]
Having an identical connection according to all my descriptions. So. Based on the MVC model. Here is such a problem. Who will come up with something about this. in smarty it would be possible to put a hook on each element. which would ask for each id - whether he has a relative in the second table. But in my case, the usual index.php template engine If, of course, you can call it that.
What are the options? Okay, let me give you a clear example. picture.
Answer the question
In order to leave comments, you need to log in
Based on the picture - you need to form a multidimensional array ready for output:
$output = array(
'FLUENCE' => array(
0 => 'Fluence 1'),
'SANDERO' => array(
0 => 'Sandero Old',
1 => 'Sandero New')
);
while($row = mysqli_fetch_assoc(mysqli_query('SELECT ... FROM ... ORDER BY ...'))){
// model = FLUENCE, modification = Fluence 1
$output[$row['model']][] = $row['modification'];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question