Thread View: adobe.golive.dynamic.content
6 messages
6 total messages
Started by Jeremy_M._Cox
Fri, 13 Aug 2004 06:24
PHP Click Count question
Author: Jeremy_M._Cox
Date: Fri, 13 Aug 2004 06:24
Date: Fri, 13 Aug 2004 06:24
15 lines
1687 bytes
1687 bytes
In theory this sounds like it would work but clearly I am doing something wrong.
I want to keep track of how many times a story is viewed. I have a table called stories. Its primary key is a column called story_ID and the counts would be kept track in a column called story views.
In order to get to a page I am using a pageParameter called showme.
At the top of the story page (all stories are viewed on this page when clicked) I added a mysql query something like this
// include ("../config/include/db.php");
// $query = "update stories set story_views = story_views + 1 where story_ID = '. pageParameter("showme" "-1") . '";
// $results = mysql_query($query);
The page paremeter sends the story_ID from the clicked headline on the previous page. In theory I thougtht this would work but to no avail. I get parsing errors and mysql_fetch_array errors
I checked online for help but I found programs for counting external links and such. In the forum all I found was a click counter in ASP. Can anyone nudge me in the right direction.
Re: PHP Click Count question
Author: Oliver_Michalak
Date: Fri, 13 Aug 2004 06:48
Date: Fri, 13 Aug 2004 06:48
11 lines
871 bytes
871 bytes
This
.pageParameter("showme" "-1").
is definitely wrong php code, but I dunno what the parameters express, so one of these might or might not work:
.pageParameter("showme", "-1").
.pageParameter("showme", -1).
...
Re: PHP Click Count question
Author: Jerry_Artman
Date: Fri, 13 Aug 2004 18:25
Date: Fri, 13 Aug 2004 18:25
5 lines
942 bytes
942 bytes
Isn't storyID a numeric field. You are enclosing it in quotes and parsing it as text.
$query = "update stories set story_views = story_views + 1 where story_ID = 1234";
$query = "update stories set story_views = story_views + 1 where story_ID = ". pageParameter("showme" "-1") ."";
Re: PHP Click Count question
Author: Oliver_Michalak
Date: Fri, 13 Aug 2004 21:01
Date: Fri, 13 Aug 2004 21:01
3 lines
955 bytes
955 bytes
@Jerry: as long as the calulation is done in PHP MySQL accepts numeric values in quotes too, but your second example points to the right direction (a comma is missing IMHO):
$query = "update stories set story_views = story_views + 1 where story_ID = ". pageParameter("showme", "-1") ."";
Re: PHP Click Count question
Author: Jeremy_M._Cox
Date: Fri, 13 Aug 2004 23:01
Date: Fri, 13 Aug 2004 23:01
1 lines
792 bytes
792 bytes
Yep that was it a missing comma. Wierd thing was it was updating the count but not displaying the page. But it works now. Thanks again.
Re: PHP Click Count question
Author: Jerry_Artman
Date: Mon, 16 Aug 2004 11:44
Date: Mon, 16 Aug 2004 11:44
1 lines
753 bytes
753 bytes
I guess I am glad I made the same mistake :-)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads