ADD function in PHP?

PSP-Heaven

New Member
Messages
428
Reaction score
0
Points
0
How can I add these two things together?
<script language="Javascript">ccount_display('1')</script>
<script language="Javascript">ccount_display('2')</script>

The first one has 2 stored as the count.
The second one has 1 stored as the count.

I want to add them both together, to get an accumulated amount of 3.

Okay, I found a way on how to make it work! But, it wont work on other pages??? Why, heres the code:
Downloads: <b>
<script language="Javascript">
var all = ccount_link[1]+ccount_link[2];
document.write(all);
</script>
 
Last edited:

The_Magistrate

New Member
Messages
1,118
Reaction score
0
Points
0
Quick answer: No, it's not possible to add those two values together with PHP.

Long answer: Because Javascript is a client-side techonology and PHP is a server-side technology, what you want to do goes the wrong way in the server->client model for websites. Because PHP is used to decide what the server has to display, and Javascript is used to decide what the client has to display, there isn't any [easy] way to get the server to add the two on the fly. You would have to send the information back to the server in a form. **What you want to do might be possible using AJAX, but I'm not totally familiar with it, so don't hold me to it.
 

PSP-Heaven

New Member
Messages
428
Reaction score
0
Points
0
I understand then. It sucks that they can't do it together. :(
What, im thinking is, saving the number to a file on the server, right? Then, calling up the file on the other pages of the website.

Downloads: <b>
<script language="Javascript">
var all = ccount_link[1]+ccount_link[2];
document.write(all);
document.save(all)
</script>

But how do i save all the variables into a file? Then, how do I call it?
 
Last edited:
Top