Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3612268
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:58:42+00:00 2026-05-18T21:58:42+00:00

I have a simple php/mysql script that stores in mysql database id, link, and

  • 0

I have a simple php/mysql script that stores in mysql database id, link, and date fields. It stores various links and some of them appear several times. I would like to count the number of times each link was accessed. I was thinking of adding new field counter and updating it every time new record is inserted, but this needs to check if the link already exists and update counter when necessary.

This means I would have to:
1. Search the entire table to look if the link already inserted.
2. If no – insert it and set counter to value of 1.
3. If yes – find the correct record and update its counter by 1.

I would like to have something like:
1. http://www.link1.com 11:20
2. http://www.link2.com 11:30
3. http://www.link1.com 11:40

http://www.link1.com counter: 2 times
http://www.link2.com counter: 1 time

I am wondering what is the best way to do that? Should I rather create a new table that stores the counter for each link?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:58:42+00:00Added an answer on May 18, 2026 at 9:58 pm

    It depends on what you need to track. Do you only need to track total number of visits? If so, add a column to your table. You don’t need to check wheter the link exists if you want to update the counter this way.

    If you need to track who visisted when etc, create a new table with a foreign key and neccesary columns to your table. With this, you need to have the id of your link, but when you update the number of visits, you should already have it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple php script on a server that's using fsockopen to connect
I have the following php script that allows me perform some calls to other
I have this simple php script <?php echo '<pre>'; // Outputs all the result
I have some code I've written in PHP for consuming our simple webservice, which
I am working on building a small php/mysql script that will act something like
Say I want to have a simple web app that takes some user input,
I have to request data for a JS-script from a MySQL database (based upon
I have a script that appends some rows to a table. One of the
I have a PHP script that imports up to 10 or so different CSV
I am pretty new to php, but I am learning! I have a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.