php - displaying the most popular pages on my site -


on homepage want display 30 popular pages on site. thought best way have hit counter each individual page, column in table called hit_counter. whenever page viewed hit_counter incremented 1.

however site has many different tables, e.g. hotels, restaurants, entertainment. want them mixed in results, not sure query pull these database.

i imagine sort of join. want take name, description , url of each row, have named columns in generic manor, e.g. hotel_name, hotel_description, hotel_url, restaurant_name, restaurant_description, etc.

then query order hit_counter desc.

so query such join, tables called restaurants, hotels , entertainment.

if i'm not mistaken, creating new table each category page. in opinion best approach if created 1 table pages, 1 categories , 1 hits. can have hotels table, restaurant table, etc., there's difference between hotels table , pages table.....hotels should store info each hotel , pages should store info each page.

anyways, category table this:

id category 

pages table should this:

id category_id url title description etc 

hits table should this:

id category_id page_id hits 

this way easier write query

'select p.url, p.description, p.title, h.hits pages p join hits h on p.id=h.page_id order h.hits desc limit 30' 

not tested idea how it.

ps: sorry if typos


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -