How to implement multi-level associated multi-dimensional arrays in PHP and Mysql?
黄舟
黄舟 2017-05-16 13:03:29
0
2
296

< /p>

As shown in the figure, a User has multiple topics, and each topic has a corresponding theme.

Please tell me how to implement this relationship using php+mysql?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
给我你的怀抱

Do you mean the actual table structure, or how to query this data form

I don’t know if you wrote it in a framework or natively

// 查詢USER表
$returndata = array();
while($userdata = mysql_fetch_assoc()) {
   
    $id = $userdata['id'];
    //跟著根據id查詢topics
    $topicssql = "";
    .....
    $userdata['topics'] = array();
    while($topicsd = mysql_fetch_assoc()) {
        $userdata['topics'][] = $topicsd; 
    }
}

给我你的怀抱

This is usually done by merging the retrieved data in the background

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template