Tooltip Toggle Concept

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
sirstrumalot
Forum Commoner
Posts: 27
Joined: Mon May 18, 2009 10:26 pm

Tooltip Toggle Concept

Post by sirstrumalot »

Okay, so here's a theoretical concept:

A tooltips system used for providing tips to using the page, consisting of jQuery JS files, a CSS file and code nested in DIVs on a page that is toggled on/off in two places: An admin page under the session of the current user that is logged in and also in the page header next to the tabs of this theoretical system where a simple option is indicated: Hints: On Off, where one is a hyperlink and the other is text, both switched when the other is clicked. When the user logs back in, the setting is saved from where it was last left off.

My question is: Is the most efficient and least-cost approach, assuming i'm using PHP and MySQL, to set that option in the database for that user? Can I use POST to do this so it's not shown in the URL? I'm assuming if the answer to the latter is yes, then I assume that means I have to use a form? Can I do it without POST and GET or a form?

Last question: If this is just a class for a div nesting text or other HTML content (photos, links, etc.), what would be the best method to turn it off once the setting has been chosen? How can the code be tight and minimal? I'm assuming it would be an IF statement querying the database for a value of a given field referencing the setting that was changed. Would that be the most efficient method?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Tooltip Toggle Concept

Post by Jonah Bron »

For any type of user settings, I think that you want a one-to-many relationship. The settings table would look like this.
[syntax]Settings_Table
-----------------------------
|ID |Type |User |Value |
-----------------------------
|1 |tooltips |302 |true |
...[/syntax]
So your query might look like this.

Code: Select all

SELECT Value FROM Settings_Table WHERE User = "$current_user" AND Type = "tooltips"
Post Reply