Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to keep track of views of a particular mysql entry

Community Beginner ,
Jul 11, 2011 Jul 11, 2011

I have a dynamic website through php and mysql. How do I get my website to keep track of the amount of views each entry got (and for the amount of views to be recorded in my mysql table? Is there an easy way to do this with dreamweaver?

TOPICS
Server side applications
638
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jul 11, 2011 Jul 11, 2011

i do have a column for views but i have do not know how the results would be inputed.

how do i use that "update statement" you mentioned to input increment view amounts in my column?

table_name has column for views.

page is a column in table that is used to dynamically display content based on title in URL parameter ie

website.com/?page=home

website.com/?page=about_us

etc.

Use query to update views+1 where page = the URL parameter that is entered into address bar to display the dynamic page content.

$pa

...
Translate
LEGEND ,
Jul 11, 2011 Jul 11, 2011

>Is there an easy way to

>do this with dreamweaver?

I don't know of a server behavior that will do this, but it's very easy to code. Everytime you retrieve the item for viewing, you also issue an update statement that increments a counter in the table. Does your 'item' table already have a column for counting views? That would probably be a good place to put it, but it's hard to say without knowing more about your database design.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2011 Jul 11, 2011

breqent,

i do have a column for views but i have do not know how the results would be inputed.

how do i use that "update statement" you mentioned to input increment view amounts in my column?

I am a beginner to php and mysql and have some difficulty venturing farther than (or even deciphering) dreamweaver's php code.

thanks,

YWSW

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 11, 2011 Jul 11, 2011

i do have a column for views but i have do not know how the results would be inputed.

how do i use that "update statement" you mentioned to input increment view amounts in my column?

table_name has column for views.

page is a column in table that is used to dynamically display content based on title in URL parameter ie

website.com/?page=home

website.com/?page=about_us

etc.

Use query to update views+1 where page = the URL parameter that is entered into address bar to display the dynamic page content.

$page = "-1"; if (isset($_GET['page'])) { $page = $_GET['page'];

$query_hits = sprintf("UPDATE table_name

SET views = views+1

WHERE page = %s", GetSQLValueString($page, "text"));

$hits = mysql_query($query_hits, $connection) or die(mysql_error());

}

best,

Shocker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2011 Jul 11, 2011
LATEST

perfect.

shockingly simple

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines