Jump to content

edit string without retrieving it?


freelance84

Recommended Posts

mysql_query("UPDATE members SET mini_guide=CONACT(mini_guide, '3a~') WHERE ID='$u_ID'");

 

This adds 3a~ to a field in a table if the user clicked hide on the html page (so when the user logs off the page 'remembers' to hide section 3a)

 

Problem is, how can i quickly remove this 3a~ if the user clicked show again?

 

It will be in a string of other hides like.....    1~5f~3a~2~

 

Is there a mysql single line that will search for the 3a~ within the string and delete it with out me first having to fetch it into php?

Link to comment
Share on other sites

*i should rename the ffield to hide_mini_guides

 

This hide and show is different per page though

 

Eg page 1 has two mini guides named 1a and 1b(at the moment), the user may wish to hide 1a but not hide 1b.

 

Therefore the only way i think to do this efficiently is to have all the guides set as default show.

 

Then  the login.php gets all the mini guide references in the "mini_guide" field and creates a session with that name accordingly, eg $_SESSION['1a'].

 

Then when page 1 loads it knows to hide mini guide 1a.

 

Is it more efficient and better design to add a new field for each guide, or put them all together in one field, or maybe even have a completely new table named mini_guides?

 

As the site grows there will be more mini guides added on different pages, and also some removed. Just having the one field with a code with in means i can add and remove mini guides with out having to add/remove fileds from the table.

 

 

With regards to structure i'm just trying my best to pick things up as i go along so any advice here would be very much appreciated 

 

*** ahh hang on. Are you saying its best not to have too many $_SESSION variables floating about? and therefore the relavent page should itself search the mysql table to determine if it should show or hide a certain miniguide?

Link to comment
Share on other sites

Does anyone else have any thoughts on this? I really don't want to be implementing something that is a poor design.

 

Any pointers on how i could optimise this procedure would be very much appreciated.

 

The system needs to be flexible as "mini guides" on my site will appear and disapear as the site grows and evolves (hopefully).

 

Each mini_guide also has a reference on my "site structure flow chart" (an actual A2 print out).

 

 

At the moment I have now a simple funtion to call in php when hiding a certain mini_guide. This simply adds to the mini_guide field the reference of the said mini_guide.

The other function is called when showing the mini_guide: It removes the reference from the mini_guide field and removes (if existing) the $_SESSION of the mini_guide, thus showing the miniguide as the default for the entire site is to show the mini guides.

 

Also, if this is poor design thinking, could you please expand a little?

Link to comment
Share on other sites

Hi

 

Splitting up the mini_guide field to determine its values would be a pain. Would be possible to do it once on log in and store it in a session variable (possibly in an object stored in a session variable, triggering table updates when it changes), but this would still be a pain (for example, what happens when there are more pages than there is space to mention in the mini_guide column.

 

Personally I would have an extra table linking the user to various pages. Can either have an entry in the table with a marker to determine whether they want to see it or not, or only have an entry in the table for that user / page if they ave chosen to see it (or chosen not to see it, which would make it easier to default to seeing all the pages).

 

All the best

 

Keith

Link to comment
Share on other sites

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.