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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:00:36+00:00 2026-05-25T14:00:36+00:00

I have a DIV #Message_PHPVARABLE that ought to appear at the bottom of a

  • 0

I have a DIV #Message_PHPVARABLE that ought to appear at the bottom of a post when a radio button assigned to this post is selected. What happens however, is that it works fine for Post_1 but when I select an option for Post_2, the option for Post_1 is changed and Message_1 displays the new selection instead of having the Post_2 selection appear in Message_2… any help? The option the radio buttons give is Like and Dislike.

$data = mysql_query("SELECT * FROM Test");
$counter = 1;

while($row = mysql_fetch_array( $data )){
?>
<script type="text/javascript">
    $(document).ready(function() {
        $("input[name*='like_<?php $counter; ?>']").click(function() {
            var defaultValue = $("label[for*='" + this.id + "']").html();
            var defaultm = "You have chosen : ";
            $('#Message_<?php $counter; ?>').html('').html(defaultm + defaultValue + ' | Value is : ' + $(this).val());
        });

    });
</script>

<div id="post_<?php $counter; ?>" class="post">
    <b><?php echo $row['Title']; ?></b><br>
    Expires: <?php echo $row['Exp']; ?><br>
<ul id="listM"></ul>
<div class="left"><p><input id="like_<?php $counter; ?>" type="radio" name="like_<?php $counter; ?>" value="1" />
<label for="like_<?php $counter; ?>">Like</label></p></div>
<div class="right"><p><input id="dislike_<?php $counter; ?>" type="radio" name="like_<?php $counter; ?>" value="0" />
<label for="dislike_<?php $counter; ?>">Dislike</label></p></div>
<hr />
</div>
<div id="Message_<?php $counter; ?>"></div>

<?php 
$counter += 1;
} 
?>

If I hard code everything (removing the $counter) then it works fine but obviously, with an infinite number of potential rows in the MySQL to be displayed, I must use variables…

  • 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-25T14:00:36+00:00Added an answer on May 25, 2026 at 2:00 pm

    You have a problem with your PHP (unless you typed your post incorrectly)

    In order to print out $counter you need to echo it. Just typing <?php $counter; ?> will not put the value into your HTML. You need to use <?php echo $counter;?> or <?=$counter;?> as a shortcut.

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

Sidebar

Related Questions

I have this item that comes in into the DOM inside a div .
i have a strange problem with jquery i have this div that shows messages
I have a div to show a message, I want the message to appear
I have a div that has a span inside that will display a message
I have a status message box (div box) positioned at the bottom of a
I have a basic div element to represent a message that I show for
So currently I have: #div { position: relative; height: 510px; overflow-y: scroll; } However
It seems that in Firefox, if I have div A with fixed width/height and
I have a div that can be revealed from several buttons on the screen.
I have a div, that I'm using JavaScript to position, so that when someone

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.