Jump to content


Photo

table cell change colour when clicked


  • Please log in to reply
5 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 09 May 2006 - 12:00 PM

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.
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 Guest_askjames01_*

Guest_askjames01_*
  • Guests

Posted 09 May 2006 - 01:22 PM

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!

#3 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 09 May 2006 - 01:36 PM

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.
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 09 May 2006 - 01:51 PM

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.

Info: PHP Manual


#5 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 09 May 2006 - 02:07 PM

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
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 09 May 2006 - 02:10 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users