i need a script that allows me to display how many times a file is downloaded please understand that i want the ability to display that on my site...giving me a script that just counts that on places it in a counter.php file or in a control panel is NO good for me i want it like this: sxc.hu/category/9001 see how it lists under each image how many times its been downloaded i couldnt find any script that gives me that ability yet. but hundreds of sites use that. any ideas??
Its not that hard, if you have a script that counts the number of downloads and uses a database to save its data it will be a quick hack into your existing code to add the number of downloads to your site. If your php skills are good, it will be a quick thing to implement. If not, you should thinking of hireing someone.
yes i already have a count scipt with database and it shows me how many clicks each link has, but only in the control panel. how do I display that number next to the link on my site??
this is my config.php file <?php # config.php # SET VARIABLES ################################# # Change your password. Very important! $password = ""; # Set the full path to this directory with trailing slash /. $full_path = "C:"; # Set your mysql database information. $db_name = ""; $db_user = ""; $db_host = ""; $db_password = ""; # # END SETTING VARIABLES ################# $mysqli = new mysqli($db_host, $db_user, $db_password, $db_name); if(mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $header_path = $full_path . "header.php"; $footer_path = $full_path . "footer.php"; ?> PHP: and this is my go.php page that the link is sent through to track: <?php # go.php include_once("config.php"); $page = (isset($_SERVER["QUERY_STRING"])) ? urldecode($_SERVER["QUERY_STRING"]):NULL; if($stmt = $mysqli->prepare("INSERT INTO clicktracker (xpage) VALUES (?)")) { $stmt->bind_param("s",$page); $stmt->execute(); $stmt->close(); } $mysqli->close(); header("Location: $page"); exit(); ?> PHP:
lets say this is my html page: <p> <a href="image1a.jpg"> <img border="0" src="image1.jpg"></a></p> <p>downloaded times</p> <p> </p> <p> <a href="image2a.jpg"> <img src="image2.jpg" ></a></p> <p>downloaded times</p> HTML: so everytime someone downloads image or image2, i want to write under how many times its downloaded
I understand, but i need much more! your image are fetched from the database, i need to see that query and alter it so it also combines this table with the table where we can find number of downloads. Then you need to show me the code where php writes the data (template, or piece of php code) and i'll make a little change in there for u.
ok i have this file as well: index.php <?php # index.php include_once("config.php"); include_once("login.php"); if(isset($_GET['delete'])) { $page = urldecode($_GET['delete']); $action = htmlspecialchars($_SERVER["PHP_SELF"]); print <<<ENDHTM <p>Are you sure you want to delete? $page</p> <form method="post" action="$action"> <p><input type="hidden" name="confirmdelete" value="$page" /> <input type="submit" value="Delete" /> <input type="button" value="Cancel" onclick="history.go(-1); return true;" /></p> </form> ENDHTM; exit(include_once($footer_path)); } if(isset($_POST['confirmdelete'])) { $confirmpage = urldecode($_POST['confirmdelete']); $stmt = $mysqli->prepare("DELETE FROM clicktracker WHERE xpage = ?"); $stmt->bind_param("s",$confirmpage); $stmt->execute(); $stmt->close(); } function cmp($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? 1 : -1; } $pageArray = array(); $stmt = $mysqli->prepare("SELECT * FROM clicktracker"); $stmt->execute(); $stmt->bind_result($xid,$xpage); while($stmt->fetch()) { array_push($pageArray, $xpage); } $stmt->close(); $mysqli->close(); $pageArray = array_count_values($pageArray); print "<table class=\"data\" cellspacing=\"0\">\n"; print "<tr><td class=\"short gray\">Clicks</td><td class=\"gray\" colspan=\"2\">Page</td></tr>\n"; uasort($pageArray, "cmp"); foreach($pageArray as $key => $val) { print "<tr><td class=\"short\">$val</td><td>$key</td><td class=\"short\"><a href=\"?delete=$key\">Delete</a></td></tr>\n"; } print "</table>\n"; include_once($footer_path); ?> PHP: and for the database, I am using mysql which was provided by my host and i installed it from my control panel there are like 100s of files in that database, what do you want to see in specific?
Lol this is going to take a long time, i want to see the script where you want the extra code to be. So the page where you display all your 'images' are? or downloads?
these are the sql queries: xid: SELECTCOUNT(*)AS`Rows`,`xid` FROM`clicktracker` GROUPBY`xid` ORDERBY`xid` LIMIT0,30 xpage: SELECTCOUNT(*)AS`Rows`,`xpage` FROM`clicktracker` GROUPBY`xpage` ORDERBY`xpage` LIMIT0,30 if you want the html page where i have all my downloads....im still not done with it....but i'll upload a rough draft so you can place the code and i'll use it once I'm done with that page. the file uploaded is albums.html sorry if im not getting it...im still learning
Normal you can do 2 things to include the number of downloads to a page. 1. Add it to your query, the query you use to display all the 'downloads' / items on the album page. 2. You create a extra query based on all ID's from the 'downloads/albums' query and combine it before using the data on the downloads/albums page. Its more work then just add a little extra code to your page..