Welcome Guest, Not a member yet? Register   Sign In
undefined variable
#3

(This post was last modified: 03-25-2017, 11:47 PM by anmol.)

no that's is not the way i was doing it.i am using index view, for all the posts and route " '/posts/' .$post['slug']);"for individual blog posts.on clicking read more, it redirects to the individual blog post, i suppose,tho i am beginner but i am assuming that.my index view is working fine but when i click on read more shows it the error, means $route['posts/(:any)']='posts/view/$1'; this is the route that does not work.my view for individual blog post is.
"<h2><?php echo $post['title'];?></h2>
<small class="post-date">postedon:<?php echo $post['created_at'];?></small><br>
<div class="post-body">
<?php echo $post['body'];?>
</div>
<hr>
<a class="btn btn-default pull-left" href="posts/edit/<?php echo $post['id'];?>">edit</a>
<?php echo form_open('/posts/delete/'.$post['id']);?><form>
<input type="submit" vlaue="delete" class="btn btn-danger">
</form>"

my route file is
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['posts/create']='posts/create';
$route['posts/update']='posts/update';
$route['posts/(:any)']='posts/view/$1';
$route['posts']='posts/index';

$route['default_controller'] = 'pages/view';
$route['(:any)']='pages/view/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
my doubt is that if it was singular $post why is it listing all the posts in the index view.and showing error only when i click on read more to see the individual blog post.if it lists all the blog post that somehow means that foreach loop is running and listing all the blog posts from the database.i have worked in laravel for a long time,and in that we create objects plural when we want all and singular when we need individual,now i for some reason have to move to codeigniter and i am feeling lost,confused here.
Reply


Messages In This Thread
undefined variable - by anmol - 03-25-2017, 12:39 PM
RE: undefined variable - by Wouter60 - 03-25-2017, 11:25 PM
RE: undefined variable - by anmol - 03-25-2017, 11:35 PM
RE: undefined variable - by Wouter60 - 03-25-2017, 11:49 PM
RE: undefined variable - by anmol - 03-25-2017, 11:56 PM
RE: undefined variable - by anmol - 03-25-2017, 11:58 PM
RE: undefined variable - by Wouter60 - 03-26-2017, 03:11 AM
RE: undefined variable - by ChicagoPhil - 03-26-2017, 01:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB