-Karl- Posted July 11, 2010 Share Posted July 11, 2010 I have a while which creates the table while ($n_row = mysql_fetch_assoc($n_result)) { echo ' <tr class="tdtitle" id="tdtitle"> <td class="main"><a href="/'.$id.'/'.$r_name.'">'.$n_name.'</a></td> <td class="textcenter">'.$n_row['members'].'</td> <td class="textcenter"><input type="text" name="col_no">Hide</td> </tr>'; } What would be the best way to go about hiding the records, with cookies, so that they're hidden the next time a visitor comes back to the site? Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/ Share on other sites More sharing options...
.josh Posted July 11, 2010 Share Posted July 11, 2010 check for cookie. If it exists, only select and echo out relevant rows. If not, select and echo out rows as normal and create cookie. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084505 Share on other sites More sharing options...
-Karl- Posted July 11, 2010 Author Share Posted July 11, 2010 Any idea how I'd do the Javascript side of it? Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084506 Share on other sites More sharing options...
.josh Posted July 11, 2010 Share Posted July 11, 2010 Okay maybe you should explain more about what you mean by "hiding" stuff? Are you wanting to be able to make the rows completely inaccessible by the user if the cookie exists? Then you don't need javascript at all. The better thing would be to not output the rows to begin with, which you'd be doing with php. Ideally you would only select the rows you need based on whether the cookie exists or not. Alternatively you would select the rows and then only actually echo out the rows you want to echo out if the cookie exists. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084509 Share on other sites More sharing options...
-Karl- Posted July 11, 2010 Author Share Posted July 11, 2010 http://www.zybez.net/search.aspx?browse=4 There's an example of what I want to do there. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084511 Share on other sites More sharing options...
Pikachu2000 Posted July 11, 2010 Share Posted July 11, 2010 http://www.zybez.net/search.aspx?browse=4 There's an example of what I want to do there. Define "example". We aren't mind readers, you know. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084540 Share on other sites More sharing options...
-Karl- Posted July 11, 2010 Author Share Posted July 11, 2010 http://www.zybez.net/search.aspx?browse=4 There's an example of what I want to do there. Define "example". We aren't mind readers, you know. Pretty self explanatory. I want to hide rows, there's a column on that page that says "Hide". That's the type of thing I'm aiming to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084617 Share on other sites More sharing options...
.josh Posted July 11, 2010 Share Posted July 11, 2010 okay well in the example you provided, it is just being able to manually filter out some paginated results...you don't really need to mess with cookies for that...simply use some javascript to change a css attribute of the td to hidden or remove it altogether... but if you are wanting to do more than that...well that's where the "we need more info" statement kicks in... Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084619 Share on other sites More sharing options...
-Karl- Posted July 11, 2010 Author Share Posted July 11, 2010 Well, the thing is, these are guides for a game. So once a user has finished a guide, I want them to be able to hide it. Then each time they visit the site the hidden guides will not be shown on the list. This will be done by cookies I assume, as the users don't need to register. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084621 Share on other sites More sharing options...
.josh Posted July 12, 2010 Share Posted July 12, 2010 Okay fair enough...sure, without requiring registration, cookies would be one of your only options. Create a new table called "hiddenGuides" with 2 columns: unique cookie id and guide id. On page load, check if the cookie exists. If it doesn't, generate a unique ID and store it in the cookie and select all rows from database. If cookie does exist, take that cookie value and only select the guides from your guide table that don't match the cookie id and guide id in hiddenGuides. When user clicks on a new row to hide, insert new row into hiddenGuides with the cookie value and guide id. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084634 Share on other sites More sharing options...
-Karl- Posted July 12, 2010 Author Share Posted July 12, 2010 Ahh, never thought about doing it like that. Thanks a lot for the idea. I always try to make things way too complicated. Quote Link to comment https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/#findComment-1084747 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.