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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:51:38+00:00 2026-06-07T06:51:38+00:00

I have a site here As you can see the timer only runs on

  • 0

I have a site here

As you can see the timer only runs on the first product. Can someone give me an idea as to how I can let the other 2 product have timer as well? Also I am having problem on the ajax part with the #bid, how to make each product has its own #bid?

<?php

include "connect.php";
$query= "select * from product";
$result= mysql_query($query);

while( $record= mysql_fetch_array($result) ){
    $product_id= $record['product_id'];
    $product_name= $record['product_name'];
    $retail_price= $record['retail_price'];
    $product_price= $record['product_price'];

    echo '<div id="product">';
    echo '<div>'.$product_name.'</div>';
    echo '<img style="width: 90%;" src="images/'.$product_id.'.png"/>';
    echo 'Retail Price';
    echo '<div>'.$retail_price.'</div>';

    echo 'Time Left';        

    $query= "select * from product where product_id='$product_id'";
    $result2= mysql_query($query);
    $record= mysql_fetch_object($result2);
    $time= $record->end_time;

    date_default_timezone_set('Asia/Singapore');
    $unix_time= strtotime($time);

    echo '<br/>

    <div id="hoursBox" style="display: inline;"></div>:

    <div id="minsBox" style="display: inline;"></div>:

    <div id="secsBox" style="display: inline;"></div>

    <br/>';

    echo 'Current Price';
    echo '<div>RM '.$product_price.'</div>';

    echo '<input type="submit" id="bid" value="Bid"/>'; 

    echo '</div>';

    } 

?>

<script type="text/javascript">

var end_time = <?php echo $unix_time; ?>;

$(document).ready(function(){

   $("#bid").click(function(){

      $.ajax({
         url: 'increase_time.php',
         type: 'post',
         data: 'end_time='+end_time,
         success: function(response){
             end_time= response;
         }
      });

   });

});

var stop= setInterval('countdown()',1000);

function countdown() {        

        var now = new Date();

        var now_time= now.getTime()/1000;
        now_time= Math.floor(now_time);

        var sec = end_time- now_time;

        if(sec<=0){
            clearInterval(stop);          
        }  

        sec= Math.floor(sec);
        var min = Math.floor(sec / 60);
        var hour = Math.floor(min / 60);

        hour %= 24;
        min %= 60;
        sec %= 60;

        document.getElementById("hoursBox").innerHTML = hour;
        document.getElementById("minsBox").innerHTML = min;
        document.getElementById("secsBox").innerHTML = sec;                 
 }
</script>

<script type="text/javascript">countdown();</script>
  • 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-07T06:51:40+00:00Added an answer on June 7, 2026 at 6:51 am

    Change your element id from class

    $("#bid").click(function(){
    
    });
    

    into

    $(".bid").click(function(){
    
     //$(this).val() and what ever for current bid
    
    });
    

    And i suggest you to use jquery countdown plugin.

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

Sidebar

Related Questions

this is my first question.. so, here we go. i have a site, 100%
It's my first time asking here (I have visited the site several times, but
We have a Joomla 1.5 site here : http://printversal.com It got hacked last night.
I have a fixed footer on my site here: http://starprovisions.com/dev/bacchanalia.html On my 1360x768 screen
I have a site showing lots of products here When you click on the
I have been following the affableBean tutorial from the NetBeans site located here .
I have a site thats served in 2 flavours, English and French. Here's some
Here's the setup. I have web site which is essentially a simple CMS. Here
Here's the scenario: I have a private site that, once logged on, will display
newbie here, so thanks in advance for help! I have a Wordpress site with

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.