Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/207429-hide-td-with-cookies/
Share on other sites

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. 

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.

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...

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.

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.

 

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.