Hello ppl,
I made a web directory for my website, and now i have a proble, I wanted to add a a counter for every link , when somebody clicks on that link I wanna increment a number from a column from my db.
So my table from db has those fields:
id - auto increment
name
link
description
respect
pics
counter
I made the scripts for inserting sites in my db and it's working well but now i really cant do that counter wright.
How can I read the value from column 'counter' and increment it, and after that update the col?
What is wrong with this script 'cause i really don't know :
<?php
require ("db.inc.php");
$result = mysql_query ('SELECT * FROM $cat WHERE id = $id');
while ($row = mysql_fetch_array ($result)){
$aduna = $row['count'];
$adaugat = $aduna ++;
mysql_query("UPDATE $cat set count='$adaugat' WHERE id='$id'");
}
echo "<div align='center'>\n";
echo "<script language='JavaScript'>\n";
echo "<!-- Begin\n";
echo "var name = navigator.appName;\n";
echo " if (name == 'Microsoft Internet Explorer')\n";
echo "url=('$link');\n";
echo "else\n";
echo "url=('$link');\n";
echo "window.location=url;\n";
echo "// End --></script></div>\n";?>
when i click the link this url will be sent :
add_hits.php?id=3&link=http://www.inforally.sibiul.ro&cat=web_auto
Can you tell me where is my mistake??
10x and see ya