0

私がこれを適切に行う方法を理解しようとしています。

print_rは次のようになります。

Array ( [0] => stdClass Object ( [quote] => "Now that's wonderful!" ) ) 

テーブルの作成:

$tmpl = array ( 'table_open'  => '<table class="table" id="quotes-table">' );
$this->table->set_template($tmpl); 
print_r($quotes);
$data = array(
    array(form_checkbox('quotes'), 'Quote'),
    array(form_checkbox('quotes'), 'Testing Quote Here'),
    array(form_checkbox('quotes'), $quotes['quote'])
);
echo $this->table->generate($data); 
?>

アップデート:

ただし、1行より多くのtを追加すると、その1行しか返されません。したがって、基本的には、クエリから返されるオブジェクトが必要です。これにより、ビューで$quote->quoteを実行できます。そうすれば、ユーザーのすべての引用符が表示されます。

<?php
$tmpl = array ( 'table_open'  => '<table class="table" id="quotes-table">' );
$this->table->set_template($tmpl);
$checkbox_data = array(
    'name'        => 'quote',
    'id'          => $quotes->id
); 
$data = array(
    array(form_checkbox($checkbox_data), 'Quote'),
    array(form_checkbox($checkbox_data), $quotes->quote)
);
echo $this->table->generate($data); 
4

2 に答える 2

2

あなたは問題が何であるかを言いませんでした、しかしあなたがあなたの見積もりを見ないならば、これを変えてみてください:

array(form_checkbox('quotes'), $quotes['quote'])

これに:

array(form_checkbox('quotes'), $quotes[0]->quote)

編集:いくつかの追加の説明。

  Array ( [0] => stdClass Object ( [quote] => "Now that's wonderful!" ) ) 

1の配列があり、それがオブジェクトです。配列の場合、オブジェクト$object->keyには$array['key']を使用します。コントローラで変更できない場合は、次のようにすることができます

$quotes = $quotes[0];
$quotes->quote;
于 2012-06-14T21:28:39.420 に答える
1

アップデートへの回答として、次のようなものを試してください。

<?php

// Your query
$results = $this->db->get('quotes')->result();

$this->table->set_heading('Name', 'Quote');

foreach ($results as $result)
{
   // The name is the user's name, not sure if that's what you were going for.
   $this->table->add_row($result->name, $result->quote);
}

echo $this->table->generate();

すべてここにあります:http://codeigniter.com/user_guide/libraries/table.html

于 2012-06-14T22:11:07.870 に答える