freelance84 Posted September 3, 2010 Share Posted September 3, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/ Share on other sites More sharing options...
trq Posted September 4, 2010 Share Posted September 4, 2010 This wreaks of poor design. What you ought to do is add another field, call it 'display', then set it to 0 for false (hide) or 1 for true (show). Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/#findComment-1107054 Share on other sites More sharing options...
freelance84 Posted September 4, 2010 Author Share Posted September 4, 2010 *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? Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/#findComment-1107151 Share on other sites More sharing options...
freelance84 Posted September 6, 2010 Author Share Posted September 6, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/#findComment-1107808 Share on other sites More sharing options...
kickstart Posted September 6, 2010 Share Posted September 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/#findComment-1107828 Share on other sites More sharing options...
freelance84 Posted September 6, 2010 Author Share Posted September 6, 2010 Ok, cool cheers Keith Quote Link to comment https://forums.phpfreaks.com/topic/212465-edit-string-without-retrieving-it/#findComment-1107915 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.