<details> <summary> php 代码教程示例:如何检索每个 php

基于数据库中mysql字段的Master => Detail关系:

公司 - 项目 - 级别

  • Adobe - Photoshop - 初学者

  • Adobe - Photoshop - 高级

  • Adobe - 插画师 - ....

  • ....

  • Microsoft - Word - 初学者

  • ....

  • 微软 - Excel - ....

我正在努力解决多级布局,也称为嵌套,仅在 HTML5 中没有 JavaScript。

我想使用带有“Select field1,field2,field3”的 sql 字符串来显示内容,就像 Windows 资源管理器样式一样。

也许有教程/示例?到目前为止,我还没有找到只使用 HTML 5 而不使用 JavaScript 的多级 php 脚本!


呼如林
浏览 99回答 2
2回答

慕田峪9158850

带有 和 的 HTML 5 解决方案<style>details {&nbsp; &nbsp; padding: 1px;&nbsp; &nbsp; background-color: #f6f7f8;&nbsp; &nbsp; margin-bottom: 1px;}details[open] {&nbsp; &nbsp; /* the style goes here */}summary {&nbsp; &nbsp; cursor: pointer;}.level_0 {&nbsp; &nbsp; margin-left: 1em;&nbsp; &nbsp; padding-left: 1em;&nbsp; &nbsp; color:red;}.level_1 {&nbsp; &nbsp; margin-left: 2em;&nbsp; &nbsp; padding-left: 1em;&nbsp; &nbsp; color:green;}.level_2 {&nbsp; &nbsp; margin-left: 3em;&nbsp; &nbsp; padding-left: 1em;&nbsp; &nbsp; color:blue;}.level_3 {&nbsp; &nbsp; margin-left: 4em;&nbsp; &nbsp; padding-left: 1em;&nbsp; &nbsp; color:gray;}</style><h4><details open>&nbsp; &nbsp; <summary&nbsp; class='level_0'>Microsoft</summary>&nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_1'>Word</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_2'>Basic</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 1</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_2'>Advanced</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 3</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; </details>&nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_1'>Excel</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_2'>Basic</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 5</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; </details></details><details open'>&nbsp; &nbsp; <summary class='level_0'>Adobe</summary>&nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_1'>Photoshop</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_2'>Basic</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 7</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_2'>Advanced</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 9</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 10&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; </details>&nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_1'>Illustrator</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <summary class='level_1'>Basic</summary>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ul class='level_3'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 11</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>Module 12&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </details>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; </details></details>

慕田峪7331174

这是我关于如何在三个数组中创建条目组合的答案。&nbsp; &nbsp; <?phpfunction combinations($arrays, $i = 0) {&nbsp; &nbsp; if (!isset($arrays[$i])) {&nbsp; &nbsp; &nbsp; &nbsp; return array();&nbsp; &nbsp; }&nbsp; &nbsp; if ($i == count($arrays) - 1) {&nbsp; &nbsp; &nbsp; &nbsp; return $arrays[$i];&nbsp; &nbsp; }&nbsp; &nbsp; // get combinations from subsequent arrays&nbsp; &nbsp; $tmp = combinations($arrays, $i + 1);&nbsp; &nbsp; $result = array();&nbsp; &nbsp; // concat each array from tmp with each element from $arrays[$i]&nbsp; &nbsp; foreach ($arrays[$i] as $v) {&nbsp; &nbsp; &nbsp; &nbsp; foreach ($tmp as $t) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result[] = is_array($t) ?&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array_merge(array($v), $t) :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array($v, $t);&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; return $result;}$arrCombi=combinations(&nbsp; &nbsp; array(&nbsp; &nbsp; &nbsp; &nbsp; array('Microsoft','Adobe','Softskills'),&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; array('Word','Excel','Photoshop','Homeoffice'),&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; array('Grundlagen','Expert')&nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; &nbsp; );$line="";foreach ($arrCombi as $k => $v){&nbsp; &nbsp; $line .= "(".implode(" AND ",$v) . ")&nbsp; OR \n";}$line=substr($line, 0, -4);echo nl2br($line);echo"<hr><pre>";print_r(&nbsp; &nbsp; combinations(&nbsp; &nbsp; &nbsp; &nbsp; array(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array('Microsoft','Adobe','Softskills'),&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array('Word','Excel','Photoshop','Homeoffice'),&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array('Grundlagen','Expert')&nbsp; &nbsp; &nbsp; &nbsp; )&nbsp; &nbsp; ));echo "</pre>";?>
打开App,查看更多内容
随时随地看视频慕课网APP