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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:27:12+00:00 2026-06-05T12:27:12+00:00

Problem: I would like to transfer by using jQuery a value in an link-attribute

  • 0

Problem:

I would like to transfer by using jQuery a value in an link-attribute to PHP/SQL query.

HTML code:

<a data-toggle="modal" href="#myModal" id="1"><i class="pull-right icon-eye-open"></i>HTML</a>

PHP code:

<div id="myModal" class="modal hide fade">
    <div class="modal-header">
      <button class="close" data-dismiss="modal">&times;</button>
      <h3>Title</h3>
    </div>
    <div class="modal-body">            
        <?php
            $query = "SELECT * FROM table WHERE id = ID FROM JQUERY HERE";
            $result = mysql_query($query) or die ('Error (' . mysql_errno() . ') ' . mysql_error());
        ?>
    </div>
    <div class="modal-footer">
      <a href="#" class="btn btn-info" data-dismiss="modal" >Close</a>
    </div>
</div>

Scenario:

When the user clicks the link-element that has data-toggle=”modal” then jQuery should take the value of the id-attribute (which is 1 in this case) and send it to the SQL-query so that the SQL query would look like:

$query = "SELECT * FROM table WHERE id = 1";

jQuery code:

$("a[data-toggle=modal]").click(function(){
    var essay_id = $(this).attr('id');
    //Find $essay set it to essay_id in PHP
    //Alternatively create a $_SESSION['EID'] here
});

Question:

How do I use jQuery to set a variable ($essay) in PHP? or how can I create a session variable in PHP through jQuery?

  • 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-05T12:27:16+00:00Added an answer on June 5, 2026 at 12:27 pm

    here is the solution ,

    <a href="#" id="1" class="push">click</a> 
    

    use a div on your modal body , like this

        <div class="modal-body">  
    
                 <div class="something" style="display:none;">
                        // here you can show your output dynamically 
                 </div>
        </div>
    

    now put data into the .something with ajax calling .please check http://api.jquery.com/jQuery.ajax/ to know more about jquery ajax.

       $(function(){
    
       $('.push').click(function(){
          var essay_id = $(this).attr('id');
    
           $.ajax({
              type : 'post',
               url : 'your_url.php', // in here you should put your query 
              data :  'post_id='+ essay_id, // here you pass your id via ajax .
                         // in php you should use $_POST['post_id'] to get this value 
           success : function(r)
               {
                  // now you can show output in your modal 
                  $('#mymodal').show();  // put your modal id 
                 $('.something').show().html(r);
               }
        });
    
    
    });
    
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a data transfer application using a servlet and would like to
Problem: I would like to share code between multiple assemblies. This shared code will
I have a problem i would like parallelize two for loops with openmp. how
I have a reasonably complex layout problem: I would like to have a main
while designing my user control, i encountered the following problem: i would like to
I have a little problem where I would like to insert a svn diff
I have an interesting genetics problem that I would like to solve in native
I have got very big problem because I would like to get more information
I need to solve a job affectation problem and I would like to find
I would like solve the problem (now hypothetical but propably real in future) of

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.