[56K WARN] Interactive Table ?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
DAFORZE
Forum Newbie
Posts: 3
Joined: Sun Mar 05, 2006 12:56 pm

[56K WARN] Interactive Table ?

Post by DAFORZE »

Heyy guys!!

Im a php beginner but i have some object oriented programming[c++ java] experience.

My problem is that I want to make a table ( for use in a front end ) wich can do two things:
change the backgroundcolor of a particular space (like A2 turns red)
know what the last space (B1 , C4 or whatever) is clicked on.

Image

For instance (like in a simple test) :
When somebody would click on B2 then it would write to a variable that the user clicked on B2
And then C3 would turn green.

So my questions are:
1 Is it possible in PHP that C3 then turns green without having the user pressing refresh
3 What is the best way too write the two functions.
2 Im really confused how to make the table, how should I write it that the table knows that for example c3 is clicked on? with a mouseevent or something?

Well thanx for reading this and ANY help or insights would be sincerely greatly appreciated.(You dont have to answer any my above questions of course :D
Thnx guyz!! :D
Last edited by DAFORZE on Sun Mar 05, 2006 1:28 pm, edited 2 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You can do it with PHP but it will require page reloads yes. It's possible to avoid the reload by using AJAX if you still need to communicate with the server. If you have no need to communicate with the server then use JavaScript.

PHP is server side, it's unaware of your client side activities for the most part ;)
DAFORZE
Forum Newbie
Posts: 3
Joined: Sun Mar 05, 2006 12:56 pm

Post by DAFORZE »

Ahh i see..
Well i have to communicate with the server so i have too use php.
I think the best way is to put a reload button on the page that the user has to press after he has finished filling in the table.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Just have the page reload automatically after each click. Either that or have javascript push the data to PHP through an iframe (easier then ajax)...


ex:

Code: Select all

<input type="button" value="click me" onClick="document.iframe.href='http://example.com/script.php?a='+this.value" />
DAFORZE
Forum Newbie
Posts: 3
Joined: Sun Mar 05, 2006 12:56 pm

Post by DAFORZE »

Now I understand that thnx!
But I have a really stupid question. :oops: Because I wrote a table but I don't even know how I can change the colors in it via php code !
I can't acces the table via php.

Code: Select all

<tr> 
<th > D0118</th> <td BGCOLOR= #FFFF00<--Can I use a php variable here instead of this color code?--> , id="B1">OPE</td><td id="B2">BUS</td><td id="B3"></td><td id="B4"></td><td id="B5"></td><td id="B6"></td>
<td id="B7"></td><td id="B8"></td><td id="B9"></td><td id="B10"></td>
</tr>
Do I have to make a different kind of table? :oops:
Or do I have to educate myself on some other topics referring this subject?
Anyway thnx!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

PHP output's a string. Simple... you make it output a tring of HTML and voila you have a web page.

Make it output a bit of HTML in an existing HTML page and you have the same result.

I know this is an RTFM comment but have you found the manual yet? http://www.php.net/

Code: Select all

<table>
    <tr>
        <td style="background-color: <?php echo '#FF0000'; ?>;">Red cell</td>
        <td style="background-color: #00FF00;">Green cell</td>
    </tr>
</table>
Post Reply