All sections @ $row _fid = "select * from ' Forum_forum ' ORDER by ' displayorder ' ASC"; $stmt = $pdo->prepare ($row _fid); $stmt Execute (); $row _forum = $stmt->fetchall (PDO::FETCH_ASSOC);//topic category foreach ($row _forum as $key = $value) {$fid = $ value["FID"];@ $sql = "Select ' typeid ', ' name ' from ' forum_topic_type ' WHERE ' fid ' = $fid"; $stmt = $pdo->prepare ($sql); $ Stmt->execute (); $row _type = $stmt->fetchall (PDO::FETCH_ASSOC);} Print_r ($row _type), $smarty, assign ("All_forum", $row _forum);
The code is for you to see the logic, but it's not successful.
Learn to Smarty time is not long
There are two tables
Forum_forum is the discussion section ID is mainly ' name ', ' FID '
Forum_topic_type is the topic of the discussion section category ID is mainly ' typeid ', ' name ', ' FID '
would have
I was going to
Forum_forum lists all the sections and adds them to the Smarty assign
Success is displayed in the list of all the sections in the foreground
But under the name of the section, I want to cycle through all the "subject categories" in this discussion section.
But found that these things (this table Forum_forum) had been circulating in the foreground,
I can't get fid to loop related topic classifications because the ID of the loop result is already in the template to get
So I thought about it. Before Smarty's assign, try a foreach to see what the results are,
and try and see if you can merge into the same group, assign, and find it a little bad.
So I would like to ask you predecessors
The solution I've thought of
1. Merging multiple table queries, but also more than one topic category ... So just give up the method
2. Do a smarty plug-in, has been tried, but also stuck can't go forward
Actually smarty this sells two times the circulation question has been troubled for a long time, but seems unable to evade again, humbly consults, hoped thoroughly to understand this kind of question
Ask for advice!
Reply to discussion (solution)
Plus, ask a question.
I use smarty myself to do modifier.xxx.php this kind of plug-in, usually is often want to smooth
But why not use a database at all?
I'm using PDO.
Because you didn't pass in the $pdo handle? But this plug-in is called directly by the template, and I can't even join $PDO
I've tried adding a database file to the plugin's function, but it also means that the database operation is incorrect.
Do you have any solutions? Or is this part of the plug-in not manipulating the database???
Which step did not succeed? $row _type not worth it?
1. Through the template processing: the Class Table association sub-class table to obtain the result set, in the Smarty assign, the template Cycle 2 times.
2. Through the program query result set processing: Returns the result set, in the program assembly becomes the string, the direct assign uploads the template.
All sections @ $row _fid = "select * from ' Forum_forum ' ORDER by ' displayorder ' ASC"; $stmt = $pdo->prepare ($row _fid); $stmt Execute (); $row _forum = $stmt->fetchall (PDO::FETCH_ASSOC); Topic category foreach ($row _forum as $key + $value) { $fid = $value ["FID"]; @ $sql = "Select ' typeid ', ' name ' from ' forum_topic_type ' WHERE ' fid ' = $fid"; $stmt = $pdo->prepare ($sql); $stmt->execute (); $row _forum[$key] [' list '] = $stmt->fetchall (PDO::FETCH_ASSOC); } Print_r ($row _forum), $smarty, assign ("All_forum", $row _forum);
Thank you, brother.
That's what it means.
Thank you so much for learning.
It's a logical question.
It seems to solve most of the two cycle problems in the future.
Thank you