[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

How to know what the previous and next messages are in an inbox that pools together all user messages in one table and uses a global auto-increment?

Asked by NeedExpertHelp in PHP and Databases

Tags: PHP

Hello,

We have a messaging system on our site that pools together all messages of all users in one database using an auto-increment and want to implement a feature that allows a user to view the PREVIOUS and NEXT message when he's viewing a message.  The problem is that since the auto-increment is global and not consecutive for a particular user, we don't know how the System can know which is the next message for that user and which is the previous message.

To help you understand what I mean, here's how it's currently working, starting with the table we are using:

-- -----------------------------------------------------
-- Table `Dating`.`Inbox`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `Dating`.`Inbox` (
  `idInbox` INT(11) NOT NULL AUTO_INCREMENT ,
  `idUsers` INT(11) NULL DEFAULT 0 ,
  `from` VARCHAR(20) NULL ,
  `to` INT(11) NULL DEFAULT 0 ,
  `subject` VARCHAR(80) NOT NULL ,
  `message` TEXT NULL ,
  `date` INT(11) NULL DEFAULT 0 ,
  `viewed` CHAR(1) NULL DEFAULT 'N' ,
  `replied` CHAR(1) NULL DEFAULT 'N' ,
  PRIMARY KEY (`idInbox`) )
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;

When a user enters the message inbox, the system controls whether there are messages for that user whose user ID corresponds with the second column which says "idUser".  So if the user's idUsers = 3, the system finds all the messages for user 3.  Then there are two other columns "viewed" and "replied" to control whether a particular message has been viewed or replied.

The links to each message in the inbox include the idUsers (unique to the user) and the idInbox (unique to the message), which auto-increments.  So, for example, if that user has 2 messages in his inbox, both messages will have idUsers = 3 in the URL, but each message will have a idInbox that is unique to that message and which auto-increments, but that are NOT necessarily consecutive.

So the problem is, if a user if viewing a message, how can the system know what is the PREVIOUS and NEXT message (idInbox) in their inbox since the auto-increment is global and not consecutive for users?

Just to be clear, here's another example.  User 3 has only 3 messages in his inbox for which the idInbox variables are 1, 7, 13.  If the user is viewing message idInbox = 7, how can the system know that the message before idInbox = 7 for idUsers = 3 is idInbox = 1 and that the next message is idInbox = 13 for that user?

How would we do that?  Or do you recommend re-doing the messaging system from scratch to make this easier to accomplish (although we prefer not to, that is an option as we're still in beta with few users).  If so, how do you suggest we do it?

Thank you very much.
[+][-]10/29/08 02:45 PM, ID: 22836057Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP and Databases
Tags: PHP
Sign Up Now!
Solution Provided By: CoyotesIT
Participating Experts: 1
Solution Grade: A
 
[+][-]10/30/08 02:44 AM, ID: 22839164Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/01/09 02:37 PM, ID: 23523383Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/07/09 03:28 PM, ID: 23580957Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_2_20070628