Jump to content

table cell change colour when clicked


joecooper

Recommended Posts

I have this 30x30 grid

www.joeyjoe.co.uk/grid.html

and i need to have it so when someone clicks any of the cells, it will change the colour (to lets say black) and who ever veiws the page, will see that same cell as black. im not asking for someone to make this script, i have good knollage of php and mysql but dont know what will be the best way of doing it, to save bandwidth ect.
Link to comment
Share on other sites

Guest askjames01
I think you are refering to CSS.
will that's not PHP anymore. It's CSS. go ahead and read the CSS document manual at the left side
of this forum.

GOOD LUCK!
Link to comment
Share on other sites

you didnt understand what i need. read it though next time please.

When a cell is clicked, a query is sent to the database to set a feild named 'select' for corodinates for that cell to 1.

and when the page is loaded, it will turn every cell background where the feild 'select' is set to 1.

but with 900 cells, it will need to do 900 querys to load a single page...

instead of doing it via tables, can easily do it by little 8x8 images.

The idea behind it is that the user can click one square per day and certain squares can have a prize behind it. but first i need to make the main bit.
Link to comment
Share on other sites

Updating on the fly is going to require something like AJAX. That doesn't have much to do with PHP except for the simple query on the backend to do the updating.

However, I don't recommend using 8x8 images for 900 cells. If you thought running 900 queries was bad (and you wouldn't have to... you could run 1 query to get the status of all the cells at once), imagine the time it would take to load 900 8x8 images.
Link to comment
Share on other sites

WHOA WHOA WHOA....

NOT a good idea to do it that way. All you have to do is add a field to each record that contains a 1 or a 0. What happens to the single record idea if you add or remove one? That's a horrible way to go about it.

I assume there are other information going along with each one of these records... so when you echo the text or associated image or whatever for the block, you can just run a simple if statement to see if the extra field is a 1 or a 0.
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.