Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to pass in your $.ajax the id of the category you want to detail.</p> <pre><code>$.ajax({ type:"POST", url:"/includes/json.php", data:['cat_id': cat_id], // passing var cat_id from the link... </code></pre> <p>Then your json.php file should be like:</p> <pre><code>&lt;?php header('X-Robots-Tag: noindex, noarchive'); $a = session_id(); if(empty($a)) session_start(); if($_SERVER['HTTP_REFERER']){ $cat_id = $_POST['cat_id']; // Grab the Id of the category you want to detail... // Here you have to fetch the info from the DB... $samples = '... WHERE cat_id = :cat'; // Create the sql here! $res = $db-&gt;prepare($samples); $res-&gt;execute(array(':cat' =&gt; $cat_id)); $count = $res-&gt;rowCount(); $htmlToDisplay = ''; if($count &gt; 0) while ($row = $res -&gt; fetch()){ $htmlToDisplay += $row['...']; // format yout output... } $resp_dialog = array( 'status' =&gt; 1, 'html' =&gt; $htmlToDisplay, ); echo json_encode($resp_dialog); }else{ header('HTTP/1.1 403 Forbidden'); exit; } ?&gt; </code></pre> <p><strong>Edit:</strong></p> <p>To create the "more details" link, try to do this:</p> <pre><code>echo "&lt;div class='sample'&gt;"; /* ... */ // Passing $row[id] to user_notice() function! echo "&lt;br /&gt;&lt;a class=\"button\" onClick=\"user_notice(this,". $row[id] ."); return false;\"&gt;More Details&lt;/a&gt;"; echo "&lt;/div&gt;"; </code></pre> <p>And then, change the <code>user_notice()</code> function to this:</p> <pre><code>function user_notice(a,cat_id){ // New parameter cat_id! download_link=$(a).attr("href"); $.ajax({ type:"POST", url:"/includes/json.php", data:{ cat_id: cat_id }, // Passing cat_id to json.php... don't forget to pass your other variables /* ... */ </code></pre> <p>Look how to pass variables through $.ajax <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">here</a></p>
 

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