Click here to Skip to main content
16,020,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Student.php -here i am getting list of students from a specific Institution in a tag
<?php
    if(isset($_POST['c_id'])) {  //input field value which contain Institution name
    $val=$_POST['c_id'];
    $sql="select RegistrationId from `students` where `Institution`='$val' ";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result)){
               $number=$row['RegistrationId'];

    ?>
    <a href='<?php echo "index.php?StudentID=$number"; ?>' target="index" id="link">
    //getting student id in the dynamic link
    <?php    echo  "$number";
     echo "<br/>";
        }}
     ?>
     <div id="index" name="index"> </div>
     <div id="Documents"> </div>
     <script>
        $(document).on('change', 'a#link', function()
        {
           $.ajax({
             url: 'Documents.php',
             type: 'get',
             success: function(html)
                {
                   $('div#Documents').append(html);
                }
                 });
        });
     </script>

In index.php - I am Getting students details based on $_GET['StudentID'] ('a' tag value)
<?php
$link=$_GET['StudentID'];
$sql = "select StudentName,Course,Age,Address from `students` where `RegistrationId`="."'".$link."'";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
echo  $row['StudentName']."<br/>";
echo $row['Course']."<br/>";
echo $row['Age']."<br/>";
echo $row['Address']."<br/>";
}
?>

In Documents.php -I am getting documents related to the speific student selected in 'a' tag
$link=$_GET['StudentID'];
$qry =  "select Image,Marksheet from `documents` where `RegistrationId`='$link'";
$result = mysql_query($qry) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$image = $row["Image"];
$image1 = $row["Marksheet"];
echo    '<embed src='. $image.'>';
echo    ' <object data='. $image1.'width="750" height="600">';
echo    '  </object>';
}

On click of student id i am trying to get result from index.php to div(index) and result from Documents.php to div(Documents) (i.e)two target for one click in tag

My code only take me to the index.php file result in a new Window Please Help me to solve this problem

What I have tried:

My code only take me to the index.php file result in a new Window

(Already asked <pre><a href="https://stackoverflow.com/questions/64292055/two-target-for-one-a-tag-and-display-two-results-in-two-different-div">here</a> no response for my question thats why i posted hERE
Posted
Updated 10-Oct-20 2:18am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900