Welcome Guest, Not a member yet? Register   Sign In
STATE: if the subject clicked was read or not yet read....
#11

[eluser]jeanel16[/eluser]
oh my URI? first time ive heard that.. (O.O) wait ill search first what uri is for xD
#12

[eluser]jeanel16[/eluser]
yes ive made it change but the bad thing is all the data where change to 1 haha.. how can i specify that the clicked subj will only be the one to change as read.. or as msg_read = 1 Sad
Code:
foreach($query1->result() as $read) {
   $read->msg_read;
   $read->id;
  
   $this->uri->segment(1);
   $data = array('msg_read' => 1);
   $this->db->where('id', $read->id);
   $this->db->update('msgdb', $data);
  }
#13

[eluser]InsiteFX[/eluser]
You need to build a data array with the message information, you do not want to loop through
it in your model.

I would create a message library and add methods to it to access the model and the updating etc.

you can then loop through the data array and add anchors to it with the msg_id.
Code:
<?php echo anchor('controller/function/'.$msg_id, 'text', $attributes); ?>

This is from Adam Griffins Auth 106 but will give you an idea of how to do it.
It uses CodeIgniters Table Class
Code:
// --------------------------------------------------------------------

/**
  * manage()
  *
  * Description:
  *
  * @access public
  * @param string
  * @return void
  */
public function manage()
{
  // Grab an array of users from the database
  $data = $this->users->users();

  // Setting headings for the table
  $this->table->set_heading('Username', 'Email', 'Actions');

  foreach($data as $value => $key)
  {
   // Build actions links
   $actions = anchor("admin/users/edit/".$key['id']."/", "Edit") . anchor("admin/users/delete/".$key['id']."/", "Delete");

   // Adding row to table
   $this->table->add_row($key['username'], $key['email'], $actions);
  }

  // Load the Auth specific view
  $this->load->view('controller/manage');
}

This would go into your controller
#14

[eluser]InsiteFX[/eluser]
Use a MY_Controller to setup the Table template.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* ------------------------------------------------------------------------
* Created by Php Designer 8.
* Date  : [[date]]
* Time  : [[time]]
* Author: Raymond L King Sr.
* The Learn CodeIgniter Development Team.
*
* Base_Controller for Table Class.
*
* ------------------------------------------------------------------------
* To change this template use File | Settings | File Templates.
* ------------------------------------------------------------------------
*/

class Base_Controller extends CI_Controller {

/**
  * --------------------------------------------------------------------
  * Class variables - public, private, protected and static.
  * --------------------------------------------------------------------
  */


  // --------------------------------------------------------------------

/**
  *  __construct
  *
  * Class Constructor PHP 5+
  *
  * @access public
  * @return void
  */
  public function __construct()
  {
   parent::__construct();

  $this->load->library('table');

  $tmpl = array (
   'table_open'   => '<table border="0" cellpadding="4" cellspacing="0">',

   'thead_open'   => '<thead>',
   'thead_close'   => '</thead>',

   'heading_row_start'  => '<tr>',
   'heading_row_end'  => '</tr>',
   'heading_cell_start' => '<th>',
   'heading_cell_end'  => '</th>',

   'tbody_open'   => '<tbody>',
   'tbody_close'   => '</tbody>',

   'row_start'    => '<tr>',
   'row_end'    => '</tr>',
   'cell_start'   => '<td>',
   'cell_end'    => '</td>',

   'row_alt_start'   => '<tr class="alt">',
   'row_alt_end'   => '</tr>',
   'cell_alt_start'  => '<td>',
   'cell_alt_end'   => '</td>',

   'table_close'   => '</table>'
  );

  $this->table->set_template($tmpl);
}


} // End of Class.

/* ------------------------------------------------------------------------
* End of file Base_Controller.php
* Location: ./application/core/MY_Controller.php
* ------------------------------------------------------------------------
*/

Then extend your controllers from the Base_Controller the file has to be saved as MY_Controller.php in ./application/core/MY_Controller.php

#15

[eluser]jeanel16[/eluser]
too many codes waaaaaaa ^__ _^
#16

[eluser]jeanel16[/eluser]
here i am again sorry for the late reply i was done for my internship time yesterday, now im facing this problem again haha... ok please explain to me what is happening to the codes you've posted here i really can't understand sorry Sad
#17

[eluser]InsiteFX[/eluser]
The Base_Controller which is saved as a ./application/core/MY_Controller.php
is extending the CI_Controller once this is done you can extend all your other
controllers from this Base_Controller and inherit it's functionality. It's creating
a CI Table Class template that you can use for generating an html table in your views.

The above manage function is a basic idea of how to get data from your model and add
rows to the html table in the view with action links back to your controller.
The action links above are link back to the controller for editing and deleting user
database records.


#18

[eluser]jeanel16[/eluser]
I finally did it i just made a uri like what u've adviced then i created a function that will catch it.... something like that... tanx a lot Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB