Active Records getting second table values in CodeIgniter - php

I create just a simple blog and I can't get my desired output from the post, all I wanted is I want to get the firstname and lastname from the second table by using the userID from the first table.
controllers/posts.php:
<?php
class Posts extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('post');
}
function index() {
$data['posts'] = $this->post->get_posts();
$data['users'] = $this->post->get_users();
$this->load->view('post_index', $data);
}
function post($postID) {
$data['post'] = $this->post->get_post($postID);
$this->load->view('post', $data);
}
function correct_permissions($required) {
$user_type = $this->session->userdata('user_type');
if ($required == "User") {
if ($user_type) {
return true;
}
} elseif ($required == "Blogger") {
if ($user_type == "Blogger") {
return true;
}
}
}
function deletepost($postID) {
$user_type = $this->session->userdata('user_type');
if ($user_type != 'Blogger') {
echo "<script>alert:('Please log in to continue.');</script>";
redirect(base_url());
}
$this->post->delete_post($postID);
redirect(base_url() . 'posts');
}
}
models/post.php
<?php
class Post extends CI_Model{
function get_posts($num=50,$start=0){
$this->db->select()->from('posts')->where('active',1)->order_by('date_added','desc')->limit($num,$start);
$query = $this->db->get();
return $query->result_array();
}
function get_post($postID){
$this->db->select()->from('posts')->where(array('active'=>1,'postID'=>$postID))->order_by('date_added','desc');
$query=$this->db->get();
return $query->first_row('array');
}
function get_user($userID){
$this->db->select()->from('users')->where(array('userID'=>$userID));
$query=$this->db->get();
return $query->first_row('array');
}
function get_users(){
$userID = $this->session->userdata('userID');
$this->db->select('firstname','lastname')->from('users')->where('userID',$userID);
$query = $this->db->get();
return $query->result_array();
}
function insert_post($data){
$this->db->insert('posts',$data);
return $this->db->insert_id();
}
function update_post($postID,$data){
$this->db->where('postID',$postID);
$this->db->update('posts',$data);
}
function delete_post($postID){
$this->db->where('postID',$postID);
$this->db->delete('posts');
}
}
and my code from views/post_index.php
<div class="panel">
<?php if (!isset($posts)) { ?>
<p>There are currently no posts on my blog.</p>
<?php
} else {
foreach ($posts as $row) {
?>
<div class="panel-heading">
<h2 href="<?= base_url() ?>posts/post/<?= $row['postID'] ?>"><?= $row['title'] ?></h2>
</div>
<div class="panel-body">
<p><?= substr(strip_tags($row['post']), 0, 200) . "..." ?></p>
<br><br>
<div class="panelver">
<h6 href="<?= base_url() ?>posts/post/<?= $row['userID'] ?>">Posted by:
<?php
if($row['userID'] == 0) {
echo "Someone";
} else {
echo $this->db->select('firstname','lastname')->from('users')->where('userID',$row['userID']);
}
?></h6>
<p href="<?= base_url() ?>posts/post/<?= $row['postID'] ?>">Added last: <?= $row['date_added'] ?></p>
</div>
<p>Read More - - - Edit | Delete</p>
<hr/>
</div>
<?php
}
}
?>
</div>
The output:
Blog Posts
this is a post blah, blah, blah..... the "posted by:" must output the
author name getting userID from the second table value using the
userID from the first table as the output below, help me! T_T...
Posted by: 2
Added last: 2014-09-20 11:30:00
Read More - - - Edit | Delete
but when I do this code:
<div class="panel">
<?php if (!isset($posts)) { ?>
<p>There are currently no posts on my blog.</p>
<?php
} else {
foreach ($posts as $row) {
?>
<div class="panel-heading">
<h2 href="<?= base_url() ?>posts/post/<?= $row['postID'] ?>"><?= $row['title'] ?></h2>
</div>
<div class="panel-body">
<p><?= substr(strip_tags($row['post']), 0, 200) . "..." ?></p>
<br><br>
<div class="panelver">
<h6 href="<?= base_url() ?>posts/post/<?= $row['userID'] ?>">Posted by:
<?php
if($row['userID'] == 0) {
echo "Someone";
} else {
echo $this->db->select('firstname','lastname')->from('users')->where('userID',$row['userID']);
}
?></h6>
<p href="<?= base_url() ?>posts/post/<?= $row['postID'] ?>">Added last: <?= $row['date_added'] ?></p>
</div>
<p>Read More - - - Edit | Delete</p>
<hr/>
</div>
<?php
}
}
?>
</div>
this will happen:
Blog Posts
this is a post blah, blah, blah..... the "posted by:" must output the author name getting userID from the second table value using the userID from the first table as the output below, help me! T_T...
The "posted by:" must output the author name getting userID from the second table value using the userID from the first table as the output below.
Posted by:
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_driver could not be converted to string
Filename: views/post_index.php
Line Number: 42
Added last: 2014-09-20 11:30:00
Read More - - - Edit | Delete
P.S: I'm a beginner programmer and new to CodeIgniter.

Ok.So what i get from your question is you have two tables with userId stored in one and user details in another.So try this as you need to get the row before echoing it.
echo $this->db->select('firstname','lastname')->from('users')->where('userID',$row['userID'])->get()->row();
the above code can also be written like this :
$this->db->select('firstname','lastname')->where('userID',$row['userID'])->get('users')->row();
Let me know if you have any doubts.

Related

Display data from three tables with common id in foreach

So I currently have three tables like this given below:
AI = auto increment.
ci_users: user_id(AI), username, slug, email, biography.
ci_terms: term_id(AI), title, slug, body.
ci_relationship: id(AI), term_id, user_id, type.
I'm trying to display all the users from a specific term_id(where type is skill),
for example, let's say term_id 3(where term_id has the title of 'CSS' from ci_terms).
To make it more clear,the above paragraph basically says show me all users with skill of CSS but I want the displayed users to show all of their other skills which are stored in the ci_relationship table.
PARAGRAPHS BELOW ARE AFTER CLICKING A SPECIFIC TERM_ID(SKILL).
This is the function which shows me all of the users that have the term_id as their skill.(from my previous Stackoverflow question. Thanks to pradeep who helped me solve that query:
// All users with specific skill
public function get_user_skill($id)
{
$this->db->select('*, count(ci_relationship.term_id)');
$this->db->from($this->table);
$this->db->join('ci_relationship', 'ci_relationship.user_id = ci_users.id', 'INNER');
$this->db->order_by('ci_relationship.user_id', 'DESC');
$this->db->group_by('ci_relationship.user_id');
$this->db->where('ci_relationship.term_id', $id);
$this->db->where('ci_relationship.type', 'skill');
$query = $this->db->get();
if($query->num_rows() > 0)
{
return $query->result();
}
else
{
return false;
}
}
As I said before the code above just display the users with the specific term_id. Now this is the method in the controller which shows the expected data(users with specific term_id):
This is my controller :
public function skill($id){
// Get data
$data['users'] = $this->User_model->get_user_skill($id);
$term = $this->Terms_model->get($id);
// Get skill name
$data['skill'] = $this->Terms_model->get($id);
// Get skills per foreach --- HERE IS WHERE I NEED HELP
$data['skills'] = $this->User_model->skills($id);
// Meta
$data['title'] = $this->settings->title.' | '. ucfirst($term->title);
// Load template
$this->template->load('public', 'default', 'users/skill', $data);
}
This is the method that I'm trying to create to displayed the term_id per user_id:
// Skill for user foreach
public function skills($id){
$this->db->select('*');
$this->db->from($this->relationship);
$this->db->where('term_id', $id);
$this->db->where('type', 'skill');
$this->db->order_by('id', 'DESC');
$query = $this->db->get();
if($query->num_rows() >= 1){
return $query->result();
} else {
return false;
}
}
The view is the following code:
<?php if($users) : ?>
<div class="row">
<?php foreach($users as $user) : ?>
<div class="col-lg-3 col-sm-6">
<div class="card text-center panel">
<div class="cardheader panel-heading" style="background: url(<?php if($user->user_id) : echo base_url('assets/img/users/covers/'.get_username($user->user_id).'/'.get_username_cover($user->user_id)); else : echo base_url().'assets/img/noavatar.jpg'; endif ?>)no-repeat center center;"></div>
<div class="avatar">
<a target="_self" href="<?= base_url('users/profile/'.get_username($user->user_id)); ?>"><img class="img-circle" alt="<?= get_username($user->user_id); ?> profile picture" title="<?= get_username($user->user_id); ?> profile picture" src="<?php if($user->user_id) : echo base_url('assets/img/users/avatars/'.get_username($user->user_id).'/'.get_username_avatar($user->user_id)); else : echo base_url().'assets/img/noavatar.jpg'; endif ?>"></a>
</div>
<div class="info panel-body">
<div class="title">
<a target="_self" href="<?= base_url('users/profile/'.get_username($user->user_id)); ?>"><?= get_username($user->user_id); ?></a>
</div>
<div class="desc"><?php if(get_occupation($user->user_id)) : ?><?= get_occupation($user->user_id); ?><?php else : echo 'No Job'; endif ?> <?php if(get_company($user->user_id)) : ?> - <b><?= get_company($user->user_id); ?></b><?php else : echo '- <b>No Company</b>'; endif ?></div>
<!-- BEGINNING OF HERE IS WHERE I NEED HELP -->
<?php if($skills) : ?>
<?php foreach($skills as $skill) : ?>
<span class="label label-orange"><?= get_term($skill->term_id) ?></span>
<?php endforeach ?>
<?php endif ?>
<!-- END OF HERE IS WHERE I NEED HELP -->
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php else : ?>
<div class="alert alert-danger">No user with <?= $skill->title ?> skill found</div>
<?php endif; ?>
This is the actual output:
And this is the expected output:
I hope I could explain myself well enough to make it easy to understand,thanks in advance.
Hope this will help you :
Create a helper method get_skill_by_user just like get_username or get_occupation and use it in your view
function get_skill_by_user($user_id, $id)
{
$ci = & get_instance();
$ci->db->select('*');
$ci->db->from('ci_relationship');
$ci->db->where('term_id', $id);
$ci->db->where('user_id', $user_id);
$ci->db->where('type', 'skill');
$ci->db->order_by('id', 'DESC');
$query = $ci->db->get();
if($query->num_rows() > 0)
{
return $query->result();
} else
{
return false;
}
}
In your view your skills loop should be like this :
<?php $user_skills = get_skill_by_user($user->user_id, $user->term_id); if($user_skills) : ?>
<?php foreach($user_skills as $skill) : ?>
<span class="label label-orange"><?= get_term($skill->term_id) ?></span>
<?php endforeach ?>
<?php endif ?>

Link to a user profile page in codeigniter

I'm trying to make a function in the CodeIgniter framework so users can click on product detail page, and see which user uploaded that certain product and they must be able to click on the product owner to go to his profile page.
Now, I am already able to echo owner information of the product owner on the details page. But the link to the owner profile page is not working some reason and the name isn't echoed anymore since I tried to make it a link.
This is my product details page (details.php) foreach loop function where I'm trying to echo the username of the owner of a product and link it to their profile page:
<?php include_once ('templates/header.php'); ?>
<div class="container">
<h3>Email van de eigenaar:</h4>
<?php
foreach($userdetail_list as $row)
{
?>
<tr>
<td><?php echo $row['email'];?></td>
</tr>
<?php } ?>
</div>
<div class="container">
<div class="row">
<div class="col-md-4" style="margin-top:24px;">
<img src="<?php echo base_url(); ?>upload/<?php echo $product['product_foto']; ?>" class="img-responsive">
</div>
<div class="col-md-5">
<h1> <div class="product_naam"> <?php echo $product['product_naam']; ?> </div> </h1>
<h3>Over dit cadeau</h3>
<div class="product_beschrijving"><?php echo $product['product_beschrijving']; ?> </div>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-default">Cadeau aanvragen</button>
<div class="aangeboden_door"> Aangeboden door: <?php
foreach($userdetail_list as $row)
{
?>
<tr>
<td><?=$row['username']; ?></td>
<td><?php echo $row['email'];?></td>
</tr>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="container">
<footer>
<p>© kadokado 2017, Inc.</p>
</footer>
<hr>
</div>
<div class="clearfix"></div>
<?php include_once ('templates/footer.php'); ?>
When I load the view page I do not see the username and no link to the users profile.
Here is my controller (User.php):
<?php
class User extends CI_Controller
{
public function index()
{
$this->load->view('profile', $data);
}
public function __construct()
{
parent::__construct();
if ($_SESSION['user_logged'] == FALSE) {
$this->session->set_flashdata("error", "Please login first to view this page!! ");
redirect("auth/login");
}
}
public function userdetails($user_id)
{
//load the User_model
$this->load->model('User_model');
//call function getdata in de Product_model
$data['userdata_list'] = $this->User_model->getdata();
//get product details
$data['user'] = $this->User_model->get_user_info($user_id);
//laad view
$data['main_content'] = 'profiel_user';
$this->load->view('profiel_user',$data);
}
public function profile()
{
$this->load->model('User_model');
if ($_SESSION['user_logged'] == FALSE) {
$this->session->set_flashdata("error", "Please login first to view this page!! ");
redirect("auth/login");
}
$this->load->view('profile');
}
}
full model file (User_model.php)
<?php
class User_model extends CI_Model {
public function getUserInfoByEmail($email)
{
$q = $this->db->get_where('users', array('email' => $email), 1);
if($this->db->affected_rows() > 0){
$row = $q->row();
return $row;
}else{
error_log('no user found getUserInfo('.$email.')');
return false;
}
}
public function getUserInfo($user_id)
{
$q = $this->db->get_where('users', array('user_id' => $user_id), 1);
if($this->db->affected_rows() > 0){
$row = $q->row();
return $row;
}else{
error_log('no user found getUserInfo('.$user_id.')');
return false;
}
}
public function getdata()
{
$this->db->where('user_id', $id);
$this->db->from('users');
$query = $this->db->get();
if($query->num_rows()>0)
{
return $query->result_array();
}
}
}
?>
Problably because of this line:
<?=$row['username']; ?>
Maybe your server does not support short hand tags?
try this:
<?php echo $row['username']; ?>
You also missed a semicolon here at the end:
echo base_url() . 'User/profiel_user?id='.$row['user_id']
and also here:
<a href="<?php echo base_url() ?>/Cadeauaanvragen">
You also use table row and table data tags without a surrounding table tag. Or remove all tr and td tags.
See: How do browsers analyze <tr> <td> without <table>?

Displaying the blog pagetitle as a url in codeigniter php

I am having a blog page where the blogs are inserted from admin panel and blog title will be inserted into new column as separated by " - " if there are spaces between the page titles.For example if the page title is " welcome to something " then in the database it is will be inserted into two columns. In once column it will be inserted as same and in other column it will be inserted as welcome-to-something.
when clicking on readmore button i need to display in url as (www.example.com/blob/article/welcome-to-something) in this format i need to display the url.
Here is the code:
Controller:
public function index()
{
$this->load->model('blogs_model');
$data["records2"] = $this->blogs_model->get_all_blogs($config["per_page"], $page);
$data['mainpage'] = "blog";
$this->load->view('templates/template',$data);
}
public function article()
{
$this->load->model('blogs_model');
$data['records2']= $this->blogs_model->getblogsdata($this->uri->segment(3));
$data['mainpage']='blogs';
$this->load->view('templates/templatess',$data);
}
Model:
function get_all_blogs()
{
$this->db->select('B.*');
$this->db->from('blogs AS B');
$this->db->where(array('B.status'=>1));
$this->db->order_by("position", "asc");
$q = $this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
function getblogsdata($id)
{
$this->db->select('blogs.*');
$this->db->from('blogs');
$this->db->where(array('blogs.blog_id'=>$id));
$q=$this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
View:
<div class="col-md-9 blogs">
<?php if(isset($records2) && is_array($records2)):?>
<?php foreach ($records2 as $r):?>
<div class="blog1">
<img src="<?php echo base_url();?>admin/images/blogimages/thumbs/<?php echo $r->image_path;?>" class="testimonials1"/>
<h3 class="heading1"><?php echo $r->blog_title;?></h3>
<div class="blogtext1 read">
<?php echo $r->description;?>
</div>
<a href="<?php echo base_url()?>blog/article/<?php echo $r ->blog_id ;?>" class="read_more7" target="_blank" >Read More</a>
</div>
<?php endforeach ;endif;?>
<div class="pagination"><?php echo $links; ?></div>
</div>
blogs table
blog_id | blog_title | blogtitle
1 welcome to something welcome-to-something
Model:
function getblogsdata($id,$slug)
{
$this->db->select('blogs.*');
$this->db->from('blogs');
$this->db->where(array('blogs.blogtitle'=>$id));
$this->db->where(array('blogs.blogtitle' => $slug));
$this->db->order_by("ne_views", "asc");
$q=$this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
View:
<a href="<?php echo base_url()?>blog/article/<?php echo $r->blogtitle;?>" class="read_more7" target="_blank" >Read More</a>

Warning: Invalid argument supplied for foreach()

I have an error in the product detail, I do not know what else to change where again. when I change $detail into $categories succeed but is the same as function submenu. It was not according to my wishes
My View
<!-- navbar -->
<div class="row">
<?php foreach ($categories as $row) : ?>
<div class="col-sm-3">
<h5><?php echo $row->categoriesName; ?></h5>
<ul><li><a href="<?php echo base_url();?>member/detail">
<?php echo $row->productName; ?></a> </li></ul>
</div>
<?php endforeach; ?>
</div>
<!-- product detail -->
<?php foreach ($detail as $details_new) : ?>
<div class="box">
<h1 class="text-center"><?php echo $details_new->productName;?></h1>
<p class="price"><?php echo $details_new->price;?></p>
</div>
<?php endforeach; ?>
My Controller
public function home() {
$data=array('title'=>'Pasar Online | Ayo Belanja Sekarang',
'username'=> $this->session->userdata('username'),
'product' => $this->product_model->all(),
'categories' => $this->categories_model->get_main(),
'isi' =>'member/index');
$this->load->view('template_home/wrapper',$data);
}
public function detail() {
$data['username'] = $this->session->userdata('username');
$data['categories'] = $this->categories_model->get_main();
$data['detail'] = $this->categories_model->get_details();
$this->load->view('member/coba',$data);
}
My Model
public function get_main(){
$this->db->select('product.*,categories.*');
$this->db->from('product');
$this->db->join('categories','product.categoriesID=categories.categoriesID');
$this->db->limit(5);
$query = $this->db->get();
if($query->num_rows() > 0) {
$results = $query->result();
} return $results;
}
public function get_details() {
$query = $this->db->query("SELECT * FROM product WHERE productID");
$row = $query->row();
}
still can not display a single product
I do not know where my mistake... please help me, thanks
you are iterating details array in wrong format.
public function get_details() {
$query = $this->db->query("SELECT * FROM product WHERE productID");
$row = $query->row();
return $row;
}
This will return only single row without any indexing like - 0,1,2...
and on view page you are using foreach loop and foreach loop use indexing to iterate value you can iterate like that --
<div class="box">
<h1 class="text-center"><?php echo $detail->productName; ?></h1>
<p class="price"><?php echo $detail->price; ?></p>
</div>
please use this way hope it will work..
In codeigniter row() selects only first row of your result in object format.So no need to use foreach loop.Just try like this...
<div class="box">
<h1 class="text-center"><?php echo $detail->productName;?></h1>
<p class="price"><?php echo $detail->price;?></p>
</div>
And
In model
public function get_details() {
$query = $this->db->query("SELECT * FROM product WHERE productID");
$row = $query->row();
return $row;
}
it is because of $detail variable is empty, no data available in this variable, always check for data in variable before looping
<?php if(!empty($detail)){
foreach ($detail as $details_new) : ?>
<div class="box">
<h1 class="text-center"><?php echo $details_new->productName;?></h1>
<p class="price"><?php echo $details_new->price;?></p>
</div>
<?php endforeach; } ?>

Getting results from giant query in codeigniter

I've been stuck for about a week now on trying to get some query results in my reply to comments module in codeigniter. I am most certainly able to insert the replies to comments and have them linked to the proper comment.
I am not able to return the results of the replies however. I have based my query structure on the comments results which I'm able to display.
Here is the code:
inserting the replies and trying to pull the results on the controller:
public function insert_airwaves_comments_replies($profile_id)
{
//echo $profile_id;
$this->load->model('account_model');
$this->load->library('session');
$this->load->helper('date');
$user = $this->account_model->user();
$session_id = $this->session->userdata['id'];
$data['user'] = $user;
$this->load->model('community_model');
$this->load->library('form_validation');
$submit = $this->input->post('sub_comment_reply');
$this->load->library('session');
$airwave = $this->community_model->get_airwave_comments($profile_id);
$data['airwave'] = $airwave;
if(isset($submit))
{
foreach($airwave as $airwave_id)
//if($this->form_validation->run() == FALSE)
// {
// $data['main_content'] = 'account/profile';
// $this->load->view('includes/templates/main_page_template', $data);
// }
// else
//{
$save_data = array(
'airwave_id' => $airwave_id['id'],
'from_id' => $session_id,
'comment' => $this->input->post('airwaves_comments_replies'),
'status' => 'active',
'datetime' => date('Y-m-d H:i:s',now())
);
$query = $this->community_model->save_airwaves_comments_replies($profile_id,$save_data);
$airwave_reply = $this->community_model->get_airwaves_comments_replies($profile_id);
$data['airwave_reply'] = $airwave_reply;
redirect('/account/profile/'.$profile_id);
}
//}
}
getting the results from the model:
public function get_airwaves_comments_replies($profile_id)
{
$session = $this->session->userdata('is_logged_in');
$user_id= $this->session->userdata('id');
if($profile_id == $user_id)
{
$comments_query = "SELECT
awr.id AS id,
awr.airwave_id AS airwave_id,
awr.from_id AS from_id,
awr.comment AS comment,
awr.status AS status,
awr.thumbsup_reply AS thumbsup_reply,
awr.datetime AS datetime,
u.first_name AS first_name
FROM
airwaves_comments_replies awr,
users u
WHERE
u.id=awr.from_id
AND awr.from_id =".$profile_id."
order by
awr.datetime
desc" ;
}
else
{
$comments_query = "SELECT awr.id AS id,
awr.airwave_id AS airwave_id,
awr.from_id AS from_id,
awr.comment AS comment,
awr.status AS status,
awr.thumbsup_reply AS thumbsup_reply,
awr.datetime AS datetime,
u.first_name AS first_name FROM airwaves_comments_replies awr,users u WHERE u.id = awr.from_id AND awr.from_id =".$profile_id." order by awr.datetime desc" ;
}
$query = $this->db->query($comments_query);
if($query->num_rows() >= 1)
{
$data = $query->result_array();
// return whole resultset. It contains zero, one or more records
return $data;
}
else return false;
}
displaying the results in my view:
if ($airwave_reply)
{
foreach ($airwave_reply as $airwave_reply_comment_row)
{ ?>
?>
<?php echo $airwave_reply_comment_row['from_id']; echo "<br />";
echo $airwave_reply_comment_row['first_name'];?>
<div class="response_structure_future">
<a name="response_<?php echo $airwave_reply_comment_row['id']; ?>"></a>
<div class="response_polaroid_future">
<a href="">
<img src='/styles/images/prof_thumbnail_2.jpg'/>
</a>
</div>
<div class="response_body_future">
<div class="response_arrow_future"></div>
<div class="response_tail_future"></div>
<div class="response_data_future">
<div class="response_name_future">
<a href="">
<?php echo $airwave_reply_comment_row['first_name'];?>says...
</a>
</div>
comment here
<div class="respond_info_future">
at <?php echo date('M d, Y',strtotime($airwave_reply_comment_row['datetime'])); ?>
<?php //if($auth->id == $replier->id || $auth->id == $result['ToUserID']) ?>
<a onclick="confirmation('');"> • delete</a>
<?php ?>
<div id="thumb_holder">
<div id="thumb_report">
<a href="mailto:info#cysticlife.org">
report
</a>
</div>
<div class= "thumb_counter" id="thumb_counter<?php// echo $reply['id']; ?>">
+<?php //echo $reply['thumbsUp_reply']; ?>
</div>
<div id="thumb_thumb">
<?php $comment_reply_id = $reply['id'];?>
<a class="myButtonLink" href="Profile.php?id=<?php //echo $prof->id; ?>" id="<?php //echo $comment_reply_id; ?>">Vote Up!</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
<a name='reply_form_<?php echo $airwave_comment_row['id']; ?>' style="clear:both"></a>
<div id='reply_to_<?php echo $airwave_comment_row['id']; ?>' class="respond_structure_future" <?php if(isset($_GET['reply_to']) && $_GET['reply_to'] == $airwave_comment_row['id']) { echo 'style="display:block;"';}else{ echo 'style="display:none;"';} ?>>
<div class="response_polaroid_future">
<a href="http://www.cysticlife.org/Profile.php?id=<?php// echo $auth->id; ?>">
<img src="/styles/images/prof_thumbnail_2.jpg" />
</a>
</div>
<?php
echo validation_errors();
echo form_open('community/insert_airwaves_comments_replies/'.$this->uri->segment(3));
?>
<div class="respond_body_future">
<div class="response_arrow_future"></div>
<div class="response_tail_future"></div>
<div class="respond_data_future">
<?php
$data = array('name' => 'airwaves_comments_replies', 'id' => 'reply_to'. $airwave_comment_row['id'].'_textarea', 'class' => 'respond');
echo form_textarea($data, set_value('airwaves_comments_replies'));
$data = array('type' => 'hidden', 'name' => 'comment', 'value' => $airwave_comment_row['id']);
echo form_input($data);
?>
<div class="respond_nevermind">
nevermind
</div>
<?php
echo form_submit('sub_comment_reply', 'Reply');
?>
</div>
</div>
</form>
</div>
please let me know what else you may need to help and thanks in advance.
What is your result right now?
With the code you are showing, your controller inserts the comment replies in a foreach-loop but redirects the user to
redirect('/account/profile/'.$profile_id)
I don't see any code where you call the view to show the comments, so i think we can't help you any further without some more explanation and code.

Categories