Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the name of the link in the where clause of php query when I click the link?
    primarykey
    data
    text
    <p>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:</p> <pre><code> $.ajax({ type:'POST', url:'activities_code.php', data: {datastr:datastr, datastr1:datastr1}, success:function(response){ $("#msg").html(response); }});}); // there are other functions before.. </code></pre> <p>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:</p> <pre><code> echo "&lt;table id=\"container\"&gt;"; $num_results = 0; while ($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) { // Here the columns of title and information are printed echo "&lt;tr&gt;&lt;td&gt;"; echo "&lt;a href='test.php' name=\"fd\" id=\"t".$t."\" target=\"_new\" class='pickanchor' onClick=\"test()\"&gt;".$row['title']."&lt;/a&gt;"; echo "&lt;br&gt;"; echo $row['PK']; echo "&lt;/td&gt;&lt;/tr&gt;"; echo "&lt;tr&gt;&lt;td&gt;"; echo $row['Information']; echo "&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>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:</p> <pre><code> &lt;?php include('connect.php'); $query = "SELECT title,Information from activities where title='?????'"; $result = mysqli_query($dbcon, $query) or die('no available data'); echo "&lt;table&gt;"; $num_results = 0; while ($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) { // Here the columns of title and information are printed echo "&lt;tr&gt;&lt;td&gt;"; echo "&lt;a href='test.php' id=\"t\".$t target=\"_new\"&gt;".$row['title']." &lt;/a&gt;"; echo "&lt;/td&gt;&lt;/tr&gt;"; echo "&lt;tr&gt;&lt;td&gt;"; echo $row['Information']; echo "&lt;/td&gt;&lt;/tr&gt;"; // Here I sum up the number of the results $num_results=$num_results+1; } ?&gt; </code></pre> <p>I am trying to find a way to put in my query, in the where clause, the name of the title that I selected:</p> <pre><code> $query = "SELECT title,Information from activities where title='?????'"; </code></pre> <p>Any help would be much appreciated. Let me know if everything is clear or I didn't explain some point clearly. Thanks. D.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload