You are here: Re: Update a counter when a link is clicked « PHP Programming Language « IT news, forums, messages
Re: Update a counter when a link is clicked

Posted by Erwin Moller on 04/27/06 10:53

Ian Davies wrote:

> Hello
>
> I have seen some tutorials to put a update a counter field in a record. I
> have the counter field in a table that also has a field for a path to
> file.
>
> I display the records in a table on a web page e.g.
>
> IndexNo ............Title................................ Link
> ................................... Count
>
......1.............MyFileName........www.mysite/files/MyFileName.doc........
> .....0
> etc
>
> User can click on the Link field in the table to download the file.
>
> The problem is I can't find a way that will run an update query along the
> lines of
>
> $Query = mysql_query("UPDATE Resources SET Count = Count + 1 WHERE
> IndexNo
> = '$IndexNo');
>
> when the user clicks the link
>
> Can anyone suggest a way or direct me to a tutorial
>
> Thanks
> Ian

Hi,

Your question is very clear, but if I understand right, this may help:

1) Make a link to a increasecounter.php and add the filename:
<a href="increasecounter.php?filename=MyFileName.doc">

2) In increasecounter.php:
$filename = $_GET["filename"];
// do your update in the db here

3) Redirect to the file
header("Location: MyFileName.doc");
exit;

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация