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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:36:20+00:00 2026-06-10T20:36:20+00:00

I have a while loop that fetches and echos status updates. I am trying

  • 0

I have a while loop that fetches and echos status updates. I am trying to echo a “REPOST” link during my while loop, so that it appends to any status update (sits below it), and when clicked, passes the ID thru to an external .php file. This link is jquery+ajax.

<script type="text/javascript">
$(document).on('click', 'a[id^=repost]', function(){
    var thePostID = $(this).prop('id').split('-')[1];
    //this now has the id of the $row['id'] we declared earlier.
    $.ajax({
        url: 'reposthandler.php',
        type: 'POST',
        data: {'id' : thePostID},
        success: function(data){  
        }
     });
});
</script>


<?php

include ('time.php');


$query = "SELECT poster, posterpic, category, type, date, id, follow.beingfollowed 
FROM usergen LEFT JOIN follow ON follow.beingfollowed = usergen.poster WHERE   
follow.iwannafollow 
= '*".$loggedin."' ORDER BY usergen.date DESC ";
$result = mysql_query($query) or die(mysql_error()) ;


$rows = array();
while($row = mysql_fetch_array($result)) {
    $row['ago'] = ago($row['date']);
    $rows[] = $row;


    echo '<br />';
    echo '<img src="' . $row['posterpic'] . '" width="40px" height="50px">';
    echo '<font color="red" size=2px><i>';
    echo '<a>'.$row['poster'].'</a></i></font>';
    echo '<br />';
    echo $row['category'] . ' for ' . $row['type'] . ' (' . $row['ago'] . ')';
    echo '<a href="#" id="repost-',$row['id'],'">REPOST</a>';
    echo '<br /><br /><HR size="4" width="auto" color="white">';
}
echo '</div>';
?>

The links are dead and do not link thru to anything. Why is this? Do I need to add something below “success: function(data)”?

  • 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-10T20:36:22+00:00Added an answer on June 10, 2026 at 8:36 pm
    Simply add an element to the loop for the button. 
    
    echo '<a href="#" id="repost-',$row['id'],'"> Repost This </a>';
    

    Bind the click function to a static parent element.

    $(document).on('click', 'a[id^=repost]', function(){
        var thePostID = $(this).prop('id').split('-')[1];
        //this now has the id of the $row['id'] we declared earlier.
        $.ajax({
            url: 'path/to/my/controller.ext?postID='+thePostID,
            type: 'POST',
            success: function(){
              //do whatever with the response.
            }
        });
    });
    

    Now you’re being passed the ID of the post you want to repost, and you can handle it however you want in your back end php file.

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

Sidebar

Related Questions

I have a while loop that loops through 3 results and echo's these out
I have a while loop that goes through a table and I echo the
I have a while loop that I use to echo multiple mysql results that
I have a while loop in php that fetches results of a query (a
I have a while loop in php that fetches assoc result of a query
I have a while loop that echos out several images. My next step is
I have a while loop that goes while a BuffedReader still has data, what
So with pygame you have a while loop that loops continuously, then your event
I have a script that uses a simple while loop to display a progress
So I have a Linux program that runs in a while(true) loop, which waits

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.