私はデータベースのフィールドの行を数えたいと思います。私のサンプルコードです。私のコード内の場所の数は何もありませんcodeigniterで見つけてください
コントローラー:
function thetotaluploads() {
$this->load->model(' num _property');
$row['no_of_uploads'] = $this->num_property->count_uploads();
echo json_encode($row['no_of_uploads']);
$this->load->view('secondpage', $row);
}
//This is my model
function count_uploads() {
$query = $this->db->query("SELECT COUNT(location) as count FROM hotels");
if ($query->num_rows() > 0) {
$row = $query->row();
return $row->count; // return the count
}
return 0; // if we get there We don't have anything.
}
ビュー:
<div class = "rightside">
<p><?php echo $_POST['location'];
?>: <?php echo $row['count']; ?> properties found</p>
</div>
エラー:
Severity: Notice
Message: Undefined variable: row
Filename: views/secondpage.php
Line Number: 87
多分、あなたが達成しようとしていることをもう少し詳しく説明したいと思うかもしれません。 –
echo '$ no_of_uploads'を' $ row ['count'] 'の代わりに表示してみてください –
ただ$ no_of_uploadsを表示します。 –