点击链接后,获取php查询的where子句中的链接名称?

I have made a website in which the users can select a value from a dropdown menu and get some information from a database. I used ajax to send the request to the database (so the page doesn't get refreshed when I send the request). Here is the part of the jquery function:

      $.ajax({
      type:'POST',
      url:'activities_code.php',
      data: {datastr:datastr, datastr1:datastr1},
      success:function(response){

        $("#msg").html(response);                           
            }});}); // there are other functions before..

The results appear on the main container of the webpage. They are composed of a title and some text. I echo the title in such a way so it is a link. I also give to each element an id and a class so I can call it later. Here is the corresponding code:

    echo "<table id=\"container\">";
$num_results = 0;
while ($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
     // Here the columns of title and information are printed
     echo "<tr><td>";
     echo "<a href='test.php' name=\"fd\" id=\"t".$t."\" target=\"_new\"  class='pickanchor' onClick=\"test()\">".$row['title']."</a>";
     echo "<br>";
     echo $row['PK'];
     echo "</td></tr>";

     echo "<tr><td>";
     echo $row['Information'];
     echo "</td></tr>"; 
 }

What I am trying to do now is: When I click on the title (which is a link), a new page to open in which a php script runs a query and show more information: Here is what I have:

     <?php
     include('connect.php');


    $query = "SELECT title,Information from activities where title='?????'";

$result = mysqli_query($dbcon, $query) or die('no available data');
echo "<table>";
$num_results = 0;
while ($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
     // Here the columns of title and information are printed
     echo "<tr><td>";
     echo "<a href='test.php' id=\"t\".$t target=\"_new\">".$row['title']."    </a>";
     echo "</td></tr>";

     echo "<tr><td>";

     echo $row['Information'];

     echo "</td></tr>";
    // Here I sum up the number of the results
     $num_results=$num_results+1;        
 }
     ?>

I am trying to find a way to put in my query, in the where clause, the name of the title that I selected:

     $query = "SELECT title,Information from activities where title='?????'";

Any help would be much appreciated. Let me know if everything is clear or I didn't explain some point clearly. Thanks. D.

You can get the title using $_GET global variable and URL parameter. Try changing this line:

echo "<a href='test.php' name=\"fd\" id=\"t".$t."\" target=\"_new\"  class='pickanchor' onClick=\"test()\">".$row['title']."</a>";

to

echo "<a href='test.php?title={$row['title']}' name=\"fd\" id=\"t".$t."\" target=\"_new\"  class='pickanchor' onClick=\"test()\">".$row['title']."</a>";

then you can get the title with these code:

$title = $_GET['title'];

make sure you sanitize the value first. I hope this will help you.

link:

PHP $_GET