douhuangjian9627 2010-11-24 16:14
浏览 36

Zend框架的新手,如何将我的php'结果'(巨大的数组)转换为像表一样可行的东西?

array(556) { ["A1"]=> string(9) "Timestamp" ["B1"]=> string(17) "Untitled Question" ["C1"]=> string(17) "Sample Question 1" ["D4"]=> string(23) "Project Scheduling 2010" ["AJ4"]=> string(4) "2011" ["D5"]=> string(13) "Send Feedback" ["J5"]=> string(4) "JUNE" ["N5"]=> string(3) "JUL"

^ - etc..is the array I'm receiving after successfully connecting to my google spreadsheet and getting a feed for 'all cells'. The problem is that I'm a novice and don't know how to take this array as a data source to convert it into something manageable like gridview/some html table equivalent.

What should I do with this array if I basically want to just read it with javascript/css to create a clone that I can work with [by that I mean it looks like a spreadsheet, in the future with some adjustments I'll be able to edit functionality - clicking a cell will open an accordian modal with information from another page etc etc...stuff Google Spreadsheets won't let me code into its interface - I want control here].

If my question is too vague/verbose I'll try to reword it.

  • 写回答

1条回答 默认 最新

  • dslfq06464 2010-11-24 16:43
    关注
    class My_View_Helper_GDataTable extends Zend_View_Helper_Abstract
    {
        public function gDataTable($data)
        {
            $firstLetter = intval('A');
            $numCols = $this->_getNumCols($data);
            $res = '<table>';
            for ($j = 1; $j <= $numRows; $j++) {
                $res .= '<tr>';
                for ($i = $firstLEtter; $i <= $firstLetter+$numCols; $i++) {
                    $res .= '<td>' . $data[$i.$j] . '</td>';
                }
                $res .= '</tr>';
            }
            $res .= '</table>';  
            return $res;          
        }
    
        protected function _getNumCols($data)
        {
            /*  
                to be implemented
                not sure how exactly can you do it
                zend gdata should offer some method for this
            */
        }
    }
    

    Then in view:

    //somewhere in view init
    $view->addHelperPath('some/path', 'My_View_Helper');
    //in your view
    $this->gDataTable($dataFromZendGdata);
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向