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 8900467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:06:18+00:00 2026-06-15T01:06:18+00:00

I am working on a project which includes image gallery.Now I want to store

  • 0

I am working on a project which includes image gallery.Now I want to store number of clicks/counts value into my database(developed in MySQL). I tried to do it in my own way, but problem is count/clicks value for all the images are stored in the database as same value.

The code given below is in the file main.php which displays images that is retrieved from database.The picture.php is the one that retrieves images from database. I have appended the code to count the number of clicks in picture.php so that it counts whenever the image is clicked.

main.php

    $query="SELECT * FROM files";
    $result=mysql_query($query) or die(mysql_error());
    while($fetch=mysql_fetch_array($result)){
         echo "<div class=single>
               <div class=wrap>
                   <a href=picture.php?fid=".$offer_id.">
                       <img src=picture.php?fid=".$offer_id."\">
                   </a>
               </div>
               </div>";
    }

picture.php

    if(isset($_GET['fid']))
    {
         include "connect.php";
         $fid=$_GET['fid'];
         $query="SELECT * FROM offers_em WHERE o_id =$fid";
         $result=mysql_query($query) or die(mysql_error());

         $sql="UPDATE offers_em SET count+=1 WHERE o_id=".$fid;
         $sql2=mysql_query($sql);
         
         $name=mysql_result($result,0,"pic_name");
         $size=mysql_result($result,0,"size");
         $type=mysql_result($result,0,"type");
         $content=mysql_result($result,0,"content");
   
         header("Content-Disposition: attachment; filename=$name");
         header("Content-length: $size");
         header("Content-type: $type");
         echo $content;
    }
    else{
         die("No file ID given...");
    }
  • 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-06-15T01:06:19+00:00Added an answer on June 15, 2026 at 1:06 am

    It has nothing to do with SQL injection.

    The problem is I’m calling the link in a loop,hence all the clicks values are getting updated.So i created a different count_link.php file and it will be called only when user click the image link.

    $query="SELECT * FROM files";
        $result=mysql_query($query) or die(mysql_error());
        while($fetch=mysql_fetch_array($result)){
             echo "<div class=single>
                   <div class=wrap>
                       <a href=count_link.php?fid=".$offer_id.">
                           <img src=picture.php?fid=".$offer_id."\">
                       </a>
                   </div>
                   </div>";
        }
    

    Anyways thanks for you time guys..:)

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

Sidebar

Related Questions

I am currently working on a PHP project which includes extensive database usage. The
I'm working on a project which includes some slightly more complex dynamic layout of
I'm working on an ASP.NET MVC 2 / .NET 3.5 project which includes SSRS
I want to start using Bing for a project which will include working out
I'm working on a project which includes generating pie and bar graph charts on
I am working on a project, which includes a searching task by entering the
I was working on a project which includes developing an application using java sockets.
I am working on a project built in WPF, which includes an embedded WebBrowser.
Currently I am working on a network project which includes connecting to tcp servers
I am working on a Dot Net project, which includes a DLL. This DLL

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.