+ Reply to Thread
Results 1 to 3 of 3

Thread: ADD function in PHP?

  1. #1
    PSP-Heaven is offline x10 Sophmore PSP-Heaven is an unknown quantity at this point
    Join Date
    May 2006
    Posts
    214

    ADD function in PHP?

    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 by PSP-Heaven; 05-27-2006 at 01:21 AM.
    Domainlagoon.com
    Win a free domain, you only need to complete a few offers. I am amazed to, you can get .com, .org, .biz, .net, and others for 9.95 points. While for 4 points you can get a .info domain. It's even better than ezyrewards.



    Before I had to switch to dial up, man I miss these speeds.


  2. #2
    The_Magistrate's Avatar
    The_Magistrate is offline x10 Elder The_Magistrate is an unknown quantity at this point
    Join Date
    May 2005
    Location
    PA
    Posts
    559

    Re: ADD function in PHP?

    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.
    Getting Started | Terms of Service | Paid Hosting | Forum Rules | Free Server Status | Banned Countries

    If I have helped you through one of my posts, please click the
    blue checkbox on the right below my avatar to add to my reputation.

  3. #3
    PSP-Heaven is offline x10 Sophmore PSP-Heaven is an unknown quantity at this point
    Join Date
    May 2006
    Posts
    214

    Re: ADD function in PHP?

    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 by PSP-Heaven; 05-27-2006 at 01:29 AM.
    Domainlagoon.com
    Win a free domain, you only need to complete a few offers. I am amazed to, you can get .com, .org, .biz, .net, and others for 9.95 points. While for 4 points you can get a .info domain. It's even better than ezyrewards.



    Before I had to switch to dial up, man I miss these speeds.


+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers