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

  • Home
  • SEARCH
  • 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 8507893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:59:53+00:00 2026-06-11T02:59:53+00:00

For some context: I’m building a blog system where user can see all the

  • 0

For some context: I’m building a blog system where user can see all the articles they add. To do so I recover the ID of the articles where username=$thatUser and use a foreach loop to display. Works find except that I want user to be able to delete those articles. A little “Are you sure?” message shows up before in a lightbox and that is where the problem is. When clicking in the button to show up the lightbox, it only show the LAST ID. See the code below:

First the lightbox code (jQuery):

    $(document).ready(function()
    {
            $('a#deleteArticleFormJS').click(function()
            {
                   $('#background,#deleteArticle').fadeIn('fast');
            });

            $('a#hideDeleteArticle, a#cancelDeleteArticle').click(function()
            {
                   $('#background,#deleteArticle').fadeOut('fast');
            });
     });

Then PHP/html code:

   <?php
      //articles(); is a basic SQL query to recover the ID
      $Articles = articles();

      foreach($Articles as $Article)
      {
    ?>
      <!-- Recover the thumnail of the articles, the ID is correct. -->
      <img src="avatar/<?php echo $Article['ID']?> - Avatar.jpg">

      <!-- Link that shows the lightbox with the "Are you sure" message, the ID is correct. -->
      <a href="#<?php echo $Article['ID'];?>" id="deleteArticleFormJS">Delete</a>

      <!-- The "lightbox". -->                      
      <div id="deleteArticle">
           //*** PROBLEM: only show the LAST ID?! ***//
           Delete <?php echo $Article['ID'];?>                              
      </div>

    <!-- End of the foreach loop -->
    <?php
    }
    ?>

My question is:
1 – How to get the proper ID in the lightbox?

If more details, code or anything is needed, please ask.

P.S: I’m not sure this is the right “StackExchange” site to put this. If not, I apologize.

  • 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-11T02:59:55+00:00Added an answer on June 11, 2026 at 2:59 am

    Try this:

    $(document).ready(function()
    {
            $('a.deleteArticleFormJS').click(function()
            {
                   $('#background,#deleteArticle'+$(this).data('article-id')).fadeIn('fast');
            });
    
            $('a.hideDeleteArticle, a.cancelDeleteArticle').click(function()
            {
                   $('#background,#deleteArticle'+$(this).data('article-id')).fadeOut('fast');
            });
     });
    
    
       <?php
          //articles(); is a basic SQL query to recover the ID
          $Articles = articles();
    
          foreach($Articles as $Article)
          {
        ?>
      <!-- Recover the thumnail of the articles, the ID is correct. -->
      <img src="avatar/<?php echo $Article['ID']?> - Avatar.jpg">
    
      <!-- Link that shows the lightbox with the "Are you sure" message, the ID is correct. -->
      <a href="#<?php echo $Article['ID'];?>" class="deleteArticleFormJS" data-article-id="<?php echo $Article['ID']; ?>" >Delete</a>
    
      <!-- The "lightbox". -->                      
      <div class="deleteArticle" id="deleteArticle<?php echo $Article['ID']; ?>" >
           //*** PROBLEM: only show the LAST ID?! ***//
           Delete <?php echo $Article['ID'];?>                              
      </div>
    
    <!-- End of the foreach loop -->
    <?php
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some context: I'm making an add-on for firefox. In firefox add-ons, js scripts can
Some context: I'm building a Django App that allows a user to pre-save an
Title said it all. Some context: I got a search mechanism - search view,
Some context here...I have a System.Windows.Window that is used to display a modal message
Some context: I'm trying to highlight all occurrences of some searched text in a
Some context: I am building a tool to be used on screen during a
To put the question into some context, the system exposing the web service uses
First of all some context : I have a form, where I post back
The whole question fits in the title. And to add some context: I'm not
First some context: all the code pasted below is within another class declared as

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.