首頁 >後端開發 >php教程 >php動態實作表格跨行跨列的程式碼

php動態實作表格跨行跨列的程式碼

WBOY
WBOY原創
2016-07-25 09:10:231252瀏覽
  1. < ?php
  2. /*
  3. * author:xudafeng@126.com
  4. * blog:http://www.xdf.me
  5. * date:2012.7.28
  6. */
  7. class danteng {
  8. function init($col1_name, $col2_name, $col3_name, $time_unit) {
  9. echo "";
  10. }
  11. function baobiao_danteng($name, $time_unit, $pro_name, $pre_name) {
  12. echo "
  13. ";
  14. for ($i = 0; $i < $time_unit; $i++) {
  15. echo "
  16. ";
  17. for ($j = 0; $j < (count($pro_name) - 1); $j++) {
  18. echo "
  19. ";
  20. for ($i = 0; $i < $time_unit; $i++) {
  21. echo "
  22. " . $col1_name . "" . $col2_name . "" . $col3_name . "
    $name" . $pro_name[0] . " " . $pre_name . $i . "";
  23. }
  24. echo "
  25. " . $pro_name[($j + 1)] . " " . $pre_name . $i . "";
  26. }
  27. echo "";
  28. }
  29. }
  30. function finish() {
  31. echo "";
  32. }
  33. }
  34. ?>
  35. 复制代码

    调用方法:

    1. $init = new danteng();
    2. $init -> init('类型', '项目', '时间单元', $time_num);
    3. $init ->; baobiao_danteng('伏羲', $time_num, $fuxi_pro, 'pre_n');
    4. $init ->; baobiao_danteng('女娲', $time_num, $nvwa_pro, '单元');
    5. $init ->; baobiao_danteng('盘古', $time_num, $pangu_pro, '啊');
    6. $init ->; baobiao_danteng('小冶', $time_num, $pangu_pro, '蛋子');
    7. $init ->; finish();
    复制代码


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn