For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > April 2006 > Re: Update a counter when a link is clicked









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Update a counter when a link is clicked
Ian Davies

2006-04-27, 7:00 pm

Thanks for your advice
Your code was just what I was looking for
It is updating the table with the counter but it is not bringing up the file
to download any more

The modified code is as follows

<a href="increasecounter.php?filename=<?php echo $Link; ?>"

The $Link returns the full path to the file (from the same table as the
count field)

In my increase counter.php I have

***************************************
$filename = $_GET["filename"];
echo $filename;
$Query = mysql_query("UPDATE Resources SET count = count + 1 WHERE Link =
'$filename'");
header("Location: $filename");
exit;
***************************************
I put the echo in just to check the file name is correct
which it is as it is used in the SQLs WHERE clause and it updates the record
as I mentioned earlier
But the file to download is not appearing. Can you see what is wrong
The address in the browser window is as follows if it helps


http://www.mysite.co.uk/increasecou...hers/MyFile.doc

which appears to be wrong
when the file was downloading previously the address would have been

http://www.mysite.co.uk/Resources/Others/MyFile.doc

Any clues
Thanks
Ian

"Erwin Moller"
< since_humans_read_this_I_am_spammed_too_
much@spamyourself.com> wrote in
message news:44507887$0$31652$e4fe514c@news.xs4all.nl...
> Ian Davies wrote:
>
I[color=darkred]
>

......1.............MyFileName........www.mysite/files/MyFileName.doc........
the[color=darkred]
>
> 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
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com