Вот мой код:Как хранить данные в базе данных с помощью cakephp?
TimesheetsController.php:
class TimesheetsController extends AppController {
public function add()
{
if (!empty($this->data)) {
if ($this->Timesheet->save($this->data)) {
$this->Session->setFlash('Your attendance has been saved.');
$this->redirect(array('action' => 'index'));
}
}
}
}
Вот мой взгляд код
add.ctp:
<table id="completed">
$this->Form->create('Timesheets');
<th>S.No</th>
<th>Name</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
<th>13</th>
<th>14</th>
<th>15</th>
<th>16</th>
<th>17</th>
<th>18</th>
<th>19</th>
<th>20</th>
<th>21</th>
<th>22</th>
<th>23</th>
<th>24</th>
<th>25</th>
<th>26</th>
<th>27</th>
<th>28</th>
<th>29</th>
<th>30</th>
<th>31</th>
echo '1'
$this->Form->input('id',array('class'=>'attendance','type'=>'hidden','label'=>false));
echo 'Karthikeyan';
$this->Form->input('1',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('2',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('3',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('4',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('5',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('6',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('7',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('8',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('9',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('10',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('11',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('12',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('13',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('14',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('15',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('16',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('17',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('18',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('19',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('20',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('21',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('22',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('23',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('24',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('25',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('26',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('27',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('28',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('29',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('30',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->input('31',array('class'=>'attendance','type'=>'text','label'=>false));
$this->Form->end('Save Attendance');
</table>
Вы уже создали модель? Я настоятельно рекомендую вам пройти учебник по блогам, прежде чем отправляться самостоятельно. http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html – xtraorange
Кроме того, я не могу сказать, находятся ли эти строки ('
') в вашем коде или просто какая-то грязная копия ... но вы определенно не хотите, чтобы они были на любом php ... и почти ни один из html не нуждается в них. – xtraorange
Я создал модель: class Timesheet extends AppModel {} – Sakthi