you_n_me_n_php Posted July 18, 2011 Share Posted July 18, 2011 Hi, I'm dong a downloads page for a band. I need to be able to count how many times each download link is clicked. The following may be helpful to know: 1. I would like to initialize the "count" for each link at some random, arbitrary number like "1500" (for marketing purposes). I don't want to start the thing at "0" and make the band look like a bunch of nobodies. 2. I would like to record each users IP address to make sure their click is unique 3. I would like to display the click numbers right next to each download link 4. The information needn't be output anywhere else (even though I will consider outputting it to a text file for later reporting purposes if the coding doesn't get out of hand. The thing has to be complete by Saturday 7/23) I was torn regarding whether or not to start writing code, as I have been advised in other forums that "providing my own answer" or telling someone "what I think" is going on can sometimes confuse the issue. Rather, as an educated beginner, it is my understanding that I should listen very closely since I have no idea where to start with this outside of the page I have herein provided. I am, however, willing to work very hard if I can be pointed in the right direction. With this in mind, I thought I should start with pseudo coding, maybe? If my approach is wrong, please advise. In general, I just need to know where to start. I guess the questions and the code will start on my end once that happens. Thanks! Roland Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 19, 2011 Share Posted July 19, 2011 Man, around here nobody likes questions from people who haven't tried to solve the problem... you should post at least some code. anyway, here are some tips: read from text file: file_get_contents(); write to text file: file_put_contents(); increment number: $variable++; get users IP: $_SERVER['REMOTE_ADDR']; Quote Link to comment Share on other sites More sharing options...
you_n_me_n_php Posted July 19, 2011 Author Share Posted July 19, 2011 thank you. Quote Link to comment Share on other sites More sharing options...
.josh Posted July 19, 2011 Share Posted July 19, 2011 well if you're just going to lie about the numbers, why bother writing script that records it? Quote Link to comment Share on other sites More sharing options...
you_n_me_n_php Posted July 19, 2011 Author Share Posted July 19, 2011 that's immaterial. but since it appears to be "open season" let's entertain your question. the answer (though probably not much more relevant to your question than is your rather lacking, Socratic, and scathing response to my original post) is simple: it has nothing to do with coding. That's the short answer. The long answer isn't as nice, and is even more pointless than your question, as it has to do with a marketing decision that I agreed upon with my client. is there a marketing forum, here? no? then I guess I am at least a little relevant and sensible, because I only conferred here on coding issues and saved my marketing dilemmas for those who are (evidently) much better suited to deal with such things. in short, i know where I am. oh, I'm sorry; we're talking about "ethics", here, not "coding" or "marketing" at all. damn! and here i was thinking all along that you were asking me to entertain a marketing decision, when all along you wanted to know why I was LYYYYYYING!!! Okay, then we should debate that, my friend, at c-h-r-i-s-t-i-a-n-i-t-ydotcom. otherwise... nevermind. Last, please consider the response from another forum (facilitated and monitored by Author Larry Ullman). My original post here on this topic was posted there, first; then I copied and pasted it onto your forum... This shouldn't be hard to do, depending upon your skill level. Here's what I would do: 1. Create a database table that records the files. 2. Create a second table that records a file ID, the user's IP address, and a timestamp. 3. For the link to download a file, use a link to a "proxy script", passing along the file ID: download_file.php?id=X 4. The download_file.php script would: A) Add a record to the second table, indicating the file ID, the IP address, and the current time. B ) Serve the file to the user. 5. To display the number of times a file has been downloaded, just do a count for that file ID on the second table. You can add any value you want to this actual count in order to inflate the numbers. That should be enough to get you started. Let us know if you have any questions or problems. This was a response directly from the author. And his kindness actually did himself more good than it did me. Imagine how many people are actually going to read it and surmise that his site (and his books) are a good place to learn PHP? Speaking of good marketing...no, I'm sorry. I promised not to talk about marketing. You almost tricked me into talking about marketing again! Shame on you!!! Don't you know where you are??? Anyhoo... I can't tell you what to think about the author's response. You are what you are (whatever that is). Maybe you're a God or something. But I would much rather have to learn PHP than decency, patience, and human kindness. After all, you can teach someone how to code functions and they will eventually get it--even if they are dumb as donuts. But you can't change the way your mother raised you. You're either fundamentally good or fundamentally fucked up. Then, too, you never really know whom you're actually talking to in these forums, do you? Well, therein (partly) may lie the problem. One day, I will write a book entitled, "And Be Careful to Entertain Strangers" or "I Dined With Angels Unawares". Again, never mind. Take care, and keep your 64 colors always in order (oh merciful, brightly hued, splendid, "ethical" and qausi-beneficent coding potentate). Quote Link to comment Share on other sites More sharing options...
.josh Posted July 19, 2011 Share Posted July 19, 2011 feel better now? btw... marketing is all about lying. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.