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

[eluser]jeanel16[/eluser]
I am creating a website in which i need to post my database table msgdb that contains

email, firstname, lastname, contactnumber,subject, message, date

and as i click on the inbox link it will display the subject, state, from and date.

at the subject column the subjects will be displayed from the msgdb, also the from (firstname, lastname) and the date.. but i dont know how to create a code in which it will be displayed if the user have read or not yet read the subject.

did you get my point? Sad
#2

[eluser]InsiteFX[/eluser]
You could create a table that will hold
Code:
id
user_id
subject_id
has_read
#3

[eluser]jeanel16[/eluser]
Sad I cant understand...

i was assigned to create a website that is like a yahoomail when you logged in you can see the inbox sent etc. i am still in my inbox.. everything is ok, the state is my only problem try logging in in your yahoomail then when you opened one of your unread messages it will eventually be unbold letters and the small square at the side of the subject will disappear because it is a sign that that msg is already read.... i dont know how to do that >.<
#4

[eluser]InsiteFX[/eluser]
Either way you need to store the value in the database, otherwise when you go back into
your inbox it will not know what the value was set to.

If the new message is stored in your msgdb just add a field to it named msg_read and set
it to either TRUE or FALSE 0 or 1 etc, you can then set the default to FALSE or 0 un-read.

So when your user reads the new message all you would need to do is update this new field.

Similar to the forums here on top Mark all posts as read.

#5

[eluser]jeanel16[/eluser]
ok tanx for the logic ill try this Smile
#6

[eluser]InsiteFX[/eluser]
I would use a tinyint(1) and set it to 0 for un-read and 1 for read.

If you can show your msgdb table I could help you more on setting it up for you
for the read and un-read.
#7

[eluser]jeanel16[/eluser]
i am creating a table using localhost/phpmyadmin

my msgdb is
id INT autoincrement primary key
msg_read TINYINT set to 0
email varchar
firstname varchar
lastname varchar
contactnumber int
subject varchar
message text
date date

i set the msg_read to 0,
is that 1 as read and 0 as unread is automatically defined in the database? that when it is set to 1 it is read already? or the programmer will be the one to set it to 1?
#8

[eluser]InsiteFX[/eluser]
When the user clicks on the message to read it you will want to access the database and update
that value to 1 for read.

Quick example add code for error handling etc.
Code:
public function mark_msg_read($msg_id = '')
{
    $data = array(
        'msg_read' => 1
    );

    $this->db->where('id', $msg_id);
    $this->db->update('msgdb', $data);
}
#9

[eluser]jeanel16[/eluser]
i made this one
Code:
foreach($query1->result() as $read) {
   $read->id;
   if(isset($_GET['id'])) {
    $data = array('msg_read' => 1);
    $this->db->where('id', $read->id);
    $this->db->update('msgdb', $data);
   }
  }

i put a $_GET['id'] to the subject that is displayed

here:

Code:
<tr><td><a href='inbox?id=&lt;?php echo $msg-&gt;id; ?&gt;'>&lt;?php echo $msg->subject;?&gt;</a></td>

i dont think this is correct
#10

[eluser]InsiteFX[/eluser]
Do not use get, use the uri class this class is automatically load!
Code:
// segments controller/function/parameters
$this->uri->segment(n)




Theme © iAndrew 2016 - Forum software by © MyBB