Xable Posted July 23, 2005 Author Share Posted July 23, 2005 (edited) ye i go it working after a bit of a fiddle.now do you know how i can view the statistics?Realy i should go buy a book, i`m sure all this is basic stuff.Thanks dman, where would i be without you Edit,what do you think about this book AmazonEdit 2,Lookin at that code again.sorry, you need to still add the backslashes and the rest of your path to the string. Somrething likeCODE$FILES_DIR = "/dll/" . $_GET['filedir']. "/";i still used$FILES_DIR = $_GET['filedir'];but changed href='download.php?file=A3D.RAR&filedir=A'tohref='download.php?file=A3D.RAR&filedir=dll/A/' Edited July 23, 2005 by Neanderthal Link to comment Share on other sites More sharing options...
dman Posted July 23, 2005 Share Posted July 23, 2005 jolly good show! It doesn't matter where you add the path, as long as it's correct when the script tries to use it.Really don't know about that book, sounds ok. I think you might be better off not using dreamweaver at first and just code in a PHP editor. This will give you better feel for the code IMHO. The PHP manual docs are really quite good, maybe look at them and search for tutes before buying anything, there is lots of free info out there.As for stats, you need some SQL code. What info do you want to present, a list of downloaded files with count? I will put together an example. Link to comment Share on other sites More sharing options...
Xable Posted July 23, 2005 Author Share Posted July 23, 2005 jolly good show!lol i don`t know anyone that speaks like that, i hear you though. Idealy, i would like to bin dreamweaver and just use notepad++. having said that though, building in DW and seing the results in code view helps a lot. and i do use notepad2 aswell.Stats, don`t realy know what`s possible but i would like to see the download count for each file.Cheers Link to comment Share on other sites More sharing options...
dman Posted July 23, 2005 Share Posted July 23, 2005 (edited) Of course you don't know anyone that speaks like that. I will rephrase "Ugh... Grunt MMMM" Better?Try this for stats (change server, user, password & db name to suit)Pretty it up as you would like.<head> <title>File Download Statistics</title></head><body><?php// Connecting, selecting database$link = mysql_connect('localhost', 'root', '') or die('Could not connect: ' . mysql_error());mysql_select_db('dlstats') or die('Could not select database');// Performing SQL query$query = 'SELECT file, count FROM dl_count order by file';$result = mysql_query($query) or die('Query failed: ' . mysql_error());$num=mysql_numrows($result);// Printing results in HTML$i=0;echo "<table><tbody>\n";echo "<tr><th>Download Count</th></tr>\n";while ($i < $num) { $fname=htmlspecialchars(mysql_result($result,$i,"file")); $fcount=trim(mysql_result($result,$i,"count")); echo "\t<tr>\n"; echo "\t\t<td>$fname</td>\n"; echo "\t\t<td>$fcount</td>\n"; echo "\t</tr>\n"; $i++;}echo "</tbody></table>\n";// Free resultsetmysql_free_result($result);// Closing connectionmysql_close($link);?> </body></html> Edited July 23, 2005 by dman Link to comment Share on other sites More sharing options...
Xable Posted July 23, 2005 Author Share Posted July 23, 2005 Typical.Erm where do i put server, user, password & db name? Link to comment Share on other sites More sharing options...
dman Posted July 23, 2005 Share Posted July 23, 2005 (edited) server will be "localhost" unless you are making a direct connection (you're not).username and password are whatever you set up. There will always be a username "root"databasename is whatever you called the database that you created the dl_count table in.$link = mysql_connect(*server*, *username*, *password*) or die('Could not connect: ' . mysql_error());mysql_select_db(*databasename*) or die('Could not select database'); Edited July 23, 2005 by dman Link to comment Share on other sites More sharing options...
Xable Posted July 23, 2005 Author Share Posted July 23, 2005 ok thought so, but how is it supposed to work. like i`ve saved it as .htm and .php both dont work. Link to comment Share on other sites More sharing options...
dman Posted July 23, 2005 Share Posted July 23, 2005 (edited) save as .php (like "showstats.php" or something)what part is not working? Edited July 23, 2005 by dman Link to comment Share on other sites More sharing options...
Xable Posted July 23, 2005 Author Share Posted July 23, 2005 i saved as count.php uploaded to server and when i load it all that shows is thisWarning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/.feliz/freedllboris/freedll.co.uk/count.php on line 7Could not connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Link to comment Share on other sites More sharing options...
dman Posted July 23, 2005 Share Posted July 23, 2005 Your "download.php" script is working ok? and you are using the same user, pwd and db name in your count.php script? Link to comment Share on other sites More sharing options...
Xable Posted July 24, 2005 Author Share Posted July 24, 2005 fixed, changed localhost to the host name. Check it out. LinkThis is great but i have 2000 + files that will be monitored. Is there a more advanced way to manage the stats?You are a massive help dman. Thank you. Link to comment Share on other sites More sharing options...
dman Posted July 24, 2005 Share Posted July 24, 2005 What do you mean by "more advanced'. What info do you want to show. You are only tracking the file name and number of downloads, but this could be modified to include date, time, requestors IP, browser type... all kinds of things. What data do you want to track is the question? You could also add filter to show only certain files or above certain level of downloads, or sort by the various fields of the db... you tell me.You might also want to consider putting your list of files in a db and creating your page of downloads on the fly with PHP in the same way as the stats. Link to comment Share on other sites More sharing options...
Xable Posted July 24, 2005 Author Share Posted July 24, 2005 (edited) i mean like having the most downloaded file at the top going down in decending order and a total download count. just some basic stats like a summary or somthing rather than just reading down a list of 2000 + files.You might also want to consider putting your list of files in a db and creating your page of downloads on the fly with PHP in the same way as the stats.this sounds very interesting. do you mean like i put the file details in a db and then the pages are auto created from the info in the db.I think that is what they do here. In their forum ppl request a file they can`t find and when the admin has found it he says, i have uploaded the file to the server and the website will be updated to show the file at 12:00a.m tonight.just like, all he does is upload the file then everynight the website auotmaticly checks for new files and updates the pages.I have thought about doing that in the past, but, as you know i am just learning the basics and thought it was best to start basic and work my way up. Is it hard though to set somthing like that up? I mean would it take long to learn. It would save a moutain of time in the long run. Edited July 24, 2005 by Neanderthal Link to comment Share on other sites More sharing options...
dman Posted July 24, 2005 Share Posted July 24, 2005 this sounds very interesting. do you mean like i put the file details in a db and then the pages are auto created from the info in the db.Yes, that's exactly what I mean. This is how the freeware page on my site operates as well. I didn't get real fancy yet but notice that I have broken the programs into groups... that is one of many ways to slice the data. I am going to add a search and filter as well.You are right, it saves a ton of edit time because you only need to change the code in one place inside the loop instead of editing each row by hand if you want to change or add something like the color or mouseover code.The php code for the count page is a pretty generic skeleton for creating this type of page, just need to expand your database and SQL selects, and give it a form to submit parameters to the code. I will try to help as I work on my site. It is good that we are both working on similar project at the same time. Your questions are helping to provoke many of my own. Link to comment Share on other sites More sharing options...
Xable Posted July 24, 2005 Author Share Posted July 24, 2005 see, you have started simple then add features later, just like i planned, but, i think it might be best to convert my site to a dynamic one now rather than later.just need to expand your database and SQL selects, and give it a form to submit parameters to the code don`t understand any of that Your questions are helping to provoke many of my own.and i bet i can`t answer any of em. Here is a mother of a Q for you though,How, exactly, do i create a datebase and have my pages dynamically constructed from it? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now