Jump to content

Archived

This topic is now archived and is closed to further replies.

joecooper

table cell change colour when clicked

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.

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
well thats a good idea, having 1 feild in the database hold 900 bytes for all of them

so like 00000010000100000101000000100000010101000 would set which ones are on / off. ill look into doing it that way

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.