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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:41:34+00:00 2026-05-16T16:41:34+00:00

I get the data from DB and display it in a div… what I

  • 0

I get the data from DB and display it in a div… what I want to do is when I click a link it should change the content of the div

one option is to pass parameter through URL to itself and reload the page…

I need to do it without reloading\refreshing…

<?php   
    $id   = '1';

    function recp( $rId ) {
        $id   = $rId;
    }
?>

<a href="#" onClick="<?php recp('1') ?>" > One   </a>
<a href="#" onClick="<?php recp('2') ?>" > Two   </a>
<a href="#" onClick="<?php recp('3') ?>" > Three </a>

<div id='myStyle'>
<?php
    require ('myConnect.php');     
    $results = mysql_query("SELECT para FROM content WHERE  para_ID='$id'");

    if( mysql_num_rows($results) > 0 ) {
        $row = mysql_fetch_array( $results );
        echo $row['para'];
    }
?>
</div>

The goal is when I click any of the links the contents of the div and php variable\s gets updated without refreshing…. so that user could see new data and after that if some query is performed it is on new variable\s

p.s I know it is gonna require some AJAX but I don’t know AJAX.. so please reply with something by which I can learn… my knowledge is limited to HTML, PHP, some JavaScript & some 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-05-16T16:41:34+00:00Added an answer on May 16, 2026 at 4:41 pm

    You’ve got the right idea, so here’s how to go ahead: the onclick handlers run on the client side, in the browser, so you cannot call a PHP function directly. Instead, you need to add a JavaScript function that (as you mentioned) uses AJAX to call a PHP script and retrieve the data. Using jQuery, you can do something like this:

    <script type="text/javascript">
    function recp(id) {
      $('#myStyle').load('data.php?id=' + id);
    }
    </script>
    
    <a href="#" onClick="recp('1')" > One   </a>
    <a href="#" onClick="recp('2')" > Two   </a>
    <a href="#" onClick="recp('3')" > Three </a>
    
    <div id='myStyle'>
    </div>
    

    Then you put your PHP code into a separate file: (I’ve called it data.php in the above example)

    <?php
      require ('myConnect.php');     
      $id = $_GET['id'];
      $results = mysql_query("SELECT para FROM content WHERE  para_ID='$id'");   
      if( mysql_num_rows($results) > 0 )
      {
       $row = mysql_fetch_array( $results );
       echo $row['para'];
      }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to get one data column from a MS-Access table and display it
I want to get data from an HTML web page, then display it in
i am developing an app in which i get data from server and display
I am trying to get to grips with how you display data from a
I want to get data from mysql database with the help of DataImportHandler so
I'm trying to get data from a database if a link is clicked. Basically
I get data from a 3rd party API that just gives me back a
How get data from mysql database? I use ASP.NET and C#.Previously, I used LINQ
I get data from server: store = new dojox.data.QueryReadStore({url:http://url_with_data}); ... myGrid = new dojox.grid.DataGrid({id:myGrid2,selectionMode:none,style:height:
i Tried to get data from excel in java. if i execute it 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.