Welcome Guest, Not a member yet? Register   Sign In
Yet another Blog tutorial question
#1

[eluser]Unknown[/eluser]
hi all,

re. the video tutorial

having searched the forum extensively !, my output consists of 4 lines, literally ______________________
______________________
______________________
______________________

I have 4 records in my entries table.

It seems to be nearly working, but instead of passing the actual posts it is outputting these lines....

CONTROLLER

<?php
class blog extends Controller {

function blog()
{
parent::Controller();
$this->load->database();

}

function index()
{
$data['title'] = "My Blog Hell";
$data['heading'] = "Load of Blog";
$data['query'] = $this->db->get('entries');


$this->load->view('blog_view', $data);
}
}
?>

VIEW:

<html>
<head>
<title><?php echo $title; ?></title>

</head>
<body>
<h1>&lt;?php echo $heading; ?&gt;</h1>



&lt;?php foreach($query->result() as $row): ?&gt;

<h3>&lt;?php $row->title ?&gt;</h3>
<p>&lt;?php $row->body ?&gt;</p>

<hr>


&lt;?php endforeach;?&gt;

&lt;/body&gt;
&lt;/html&gt;


any pointers grafully appreciated.
#2

[eluser]deviant[/eluser]
Change

Code:
<h3>&lt;?php $row->title ?&gt;</h3>
<p>&lt;?php $row->body ?&gt;</p>

to

Code:
<h3>&lt;?php echo $row->title; ?&gt;</h3>
<p>&lt;?php echo $row->body; ?&gt;</p>

or if you want to use the shortened syntax

Code:
<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>
#3

[eluser]garymardell[/eluser]
Code:
<h3>&lt;?php $row->title ?&gt;</h3>
<p>&lt;?php $row->body ?&gt;</p>

is the problem, your not echoing anything.

The lines are the hrs

Code:
<h3>&lt;?=$row->title;?&gt;</h3>
<p>&lt;?=$row->body;?&gt;</p>

or

Code:
<h3>&lt;?php echo $row->title; ?&gt;</h3>
<p>&lt;?php echo $row->body; ?&gt;</p>

They mean the same thing &lt;?= is the short way of writing &lt;?php echo

Edit deviant beat me to it...
#4

[eluser]Unknown[/eluser]
Thanks, guys.

i AM willing to look stupid in order to learn this thing ;>

POC
#5

[eluser]monfreex[/eluser]
One of the things I love about the CI community is that there is no such thing as a stupid or silly question. Everyone is willing to extend a helping hand to those who need it. :-)




Theme © iAndrew 2016 - Forum software by © MyBB