Little Help Please

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
Forum Newbie
Posts: 2
Joined: Tue Aug 17, 2010 3:35 pm

Little Help Please

Post by shadowc »

Am trying to make a click counter in php and mysql, but all i can do, i make hit counter it only counts every hit on the web where links are shown. Here's what i've done so far:

if you choose to help me here are the fields in the database:
mysql_select_db("DATABASE", $con);

$result = mysql_query("SELECT * FROM links ORDER BY hits DESC LIMIT 15");

while($row = mysql_fetch_array($result))
echo "<a href=$row[Link]>$row[Name]</a>";
echo "<br/>";

mysql_query("UPDATE links SET hits=hits+1");
I try to make it like this but it wont count at all:
while($hits= mysql_fetch_array($result))
mysql_query("UPDATE links SET hits=hits+1 WHERE Link =$link");
Before i reached here everything went well, but here i totally blocked :banghead: , so if anyone could help me would be the best thing, Thanks.
Forum Newbie
Posts: 7
Joined: Thu Aug 19, 2010 7:07 am

Re: Little Help Please

Post by Dev_Mah »

hi sir,

i try to solve this problem ,and this is

$query = "SELECT * FROM links order by links_id";
$result = mysql_query($query,$link)
or die(mysql_error());

<table class="aatable">
<th ></th>


while ($row = mysql_fetch_array($result)) {
$links_id = $row['links_id '];
$links_name = $row['links_name '];
$links_hits = $row['hits'];

echo "<tr>";
echo "<td>".$links_id."</td>";
echo "<td >".$links_name."</td>";
echo "<td>".$links_hits."</td>";

<td><a href="links_count.php?action=edit&id=<?php echo $row['$links_id']; ?>">counter</a> </td>

///////////////////////////////////////////////in [links_count]//////////////////
$updatesql = "SELECT hits FROM links
WHERE links_id='".$_GET['id']."'";
$result = mysql_query($updatesql)
or die("Invalid query: " . mysql_error());

$sql="UPDATE links SET hits='$hits',
WHERE links_id='".$_GET['id']."'";

i hope to solve the problem .....
any question i will replay ...
iam ready to help you...
Post Reply