I have a download page in my wapsite and each file details has enterd to a mysql database, i want to show how many times downloaded each file, its UPDATE table SET +1 Like Something arround it, But i dont know it correctly please someone help me pls
I want help in mysql please read this
Collapse
X
-
If the files table name 'files' , downloads counter column name 'downloads' and auto increment file id column name 'id' that you can use the following sql command. $id is the file id of user going to download.
UPDATE `files` SET `downloads`=`downloads`+1 WHERE `id`=$id
Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.
-
Ok, check this one
Code:<?php $mysqlserver = 'localhost'; $database = 'DTABASENAME'; $db_user = 'USERNAME'; $db_pass = 'PASSWORD'; $link = mysql_connect($mysqlserver, $db_user, $db_pass) or die('Could not connect to Database'); $db_id = mysql_select_db($database, $link) or die('Could not select Database'); $title = "YOUR-FILE-TITLE"; mysql_query("UPDATE `example` SET `hits`=`hits`+1 WHERE `title`=$title");
Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.
Comment
-
mysql_query("UPDATE example SET hits=hits+'1' WHERE id='$fileid'");My Blog: http://jhommark.blogspot.com
My Facebook: http://www.facebook.com/jhommark
My Official Site: http://www.undergroundweb.tk
My Community Site: http://undergroundwap.xtreemhost.com
Comment
-
This is the Code. Please help me to correct it..
<?php mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
echo $row['url']; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
Comment
-
Originally posted by jayasrilanka View Post<?php mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
echo $row['url']; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'www.facebook.com', '/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET[']);" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a onclick="_gaq.push(['_trackEvent', 'Outgoing', 'twitter.com', '/home?status=<?php echo $_GET[']);" rel="nofollow" href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
change your code like this:
PHP Code:<?php
session_start();
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
$_SESSION['link']=$row['url'];
echo "load.php?file=$id"; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
make load.php with this code
PHP Code:
<?php
session_start();
$id = $_GET['file'];
$link=$_SESSION['link'];
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$done=mysql_query("UPDATE example SET hits=hits+1 WHERE title='".$id."'");
if($done)
{
header("Location: $link");
exit();
}
?>PHP Code:/* I don't know everything hehe */
Comment
-
Originally posted by jayasrilanka View PostIts displaying error:
Download ape_game_thibena.mp3Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jayasri6/public_html/dl/index.php:2) in/home/jayasri6/public_html/dl/index.phpon line6
PHP Code:<?php
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
echo "load.php?file=$id"; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
PHP Code:<?php
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$link=mysql_fetch_array(mysql_query("SELECT url FROM example WHERE title='".$id."'"));
$done=mysql_query("UPDATE example SET hits=hits+1 WHERE title='".$id."'");
if($done)
{
header("Location: $link[0]");
exit();
}
?>PHP Code:/* I don't know everything hehe */
Comment
Comment