extracting info

  • i need help again. I am creating a forum and I need to know how to extract the last user to reply to a certain category of topic. This is displayed in the main page. can anyone help me?


    eat when you can and not when you cannot.

  • Pardon the blandness of the code, but I can only guess at the table design you are working with.

    Assuming the following:

    -ForumUsers table has all forum user data and has a key field UserID

    -ForumMessageTable holds all forum thread data with a foreign key of CategoryID that is the key for the category that each message applies to.

    -@mycategory is the categoryID of the category you are interested in

    -- Begin SQL Code --

    Select username

    from ForumUsers

    where UserID in

    (

    Select Top 1 UserID

    from ForumMessageTable

    Where CategoryID = @mycategoryid

    Order by MessageDate desc

    )

    That is a very simple example. Again, your forum may be more complex and may need a different approach.

    Good Luck,

    Al


    "I will not be taken alive!" - S. Hussein

  • -- be sure a DateTime field name is in your table

    -- be sure the DateTime field name is indexed

    -- Begin complex SQL Code --

    Select username, catagory, datetimefield

    from ForumTable

    where datetimefield =

    (Select MAX(datetimefield)

    from ForumTable)

    -- End complex SQL code --

    -- since datetime is accurate enough

    -- to capture users sequentially as

    -- they input you'll have one per user

    -- but you'll have to query this often

    -- to keep your front page updated per new

    -- user session, try using ...

    setTimeout("checkCatagory()", 20000);

    -- in javascript to only fire lookup

    -- per new user by each client session

    -- checkCatagory can run SP & retrieve data

    -- & redisplay your front page on front page


    Regards,

    Coach James

  • thanks so much....

    I am going to try this and I believe it will work. Thanks again!

     

     


    eat when you can and not when you cannot.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply