Jump to content

Recommended Posts

hi,

on a news program i made i want to allow my members to see what new articles were made since they last visited the site. pretty much what i want to do is exactly how phpbb and other bbs programs do.

now looking at them i applied the same method but it doesnt seem to work.

first off i added a colume last_visit which would have the last time they visited the site(in time())

then i made it do a search with the following query:

[code]SELECT * FROM metal_posts WHERE Date>='$last_visit'[/code]

now doing it that displayed 0 results everytime no matter what. changed >= to <= just displayed all of the news articles.

so question is, what am i doing wrong?

to let you know all the dates on my program are in time() format so format issue isnt the problem here.

thanks
make sure you ARE using a timestamp for both variable types. That is a timestamp for the last login and a tiemstamp for the ews article. Assuming that is all in order, make suer you are assiging a value to last vistit

It may be that you instead use a join on the tables liek so....
[code]<?php
$qry = "SELECT `metal_posts`.* FROM `metal_posts`, `user` WHERE `metal_posy`.`Date` >= `user`.`lastlogin` AND `user`.`id` = $_SESSION['id']";
$qry = mysql_query($qry);
......[/code]
Now the field names need to be matched up (unless I am teh best guesser in the world!) but that should not be a problem! and the $_SESSION can be what ever you use to identify the user 9again I assume you use sessions witch may not be the case....
actually im using cookies ;)

and i got the problem solved, though now i have another problem.

to solved it i forgot i had to check the read table i made.

now i still have one issue and thats getting the correct number result. tried looping it but it doesnt seem to want to do that.

here is how im doing that:

[code] while ($row = mysql_fetch_assoc($search_result)) {

$db->run = "select * from post_read WHERE Topic='$row[tid]' and user='$logged_user'";
$t_num = $db->num_results();
$db->close();
}[/code]

i might be missing something but i cant think of what that is. if someone here knows, please tell me.

thanks.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.