How to make PHP variables queired from SQL table to pass to "iframe" as url?
<p>I have the script below. The resulting record from array is okay except that when I use it in "iframe" as auto url, it always point to the first record, which is accounting.php.</p>

<pre><code>$sql="SELECT DISTINCT(b.dept_name) as title, count(dept_name) AS count, REPLACE( b.dept_name, ' ', '-' ) AS urlink FROM position a, department b WHERE a.pos_dept=b.dept_code GROUP BY b.dept_name HAVING count &gt; 1";

if ($result=mysqli_query($link,$sql))
{
// Fetch one and one row

while ($row=mysqli_fetch_row($result))
{
$dept=$row[0];
$count=$row[1];
$urlink=strtolower($row[2].'.php');

echo '&lt;a href="#popup" class="popup-link"&gt;'.$dept.' - ( '.$count.'     '.$urlink.')&lt;/a&gt;&lt;p&gt;&lt;div class="popup-wrapper" id="popup"&gt;&lt;div class="popup-container"&gt;&lt;iframe src="'.$urlink.'" width="100%" height="500"&gt;&lt;/iframe&gt;&lt;a class="popup-close" href="#closed"&gt;X&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;';

}

mysqli_free_result($result);
}
</code></pre>

<p>I tried to run without the "iframe" to debug and the $urlink is correct and changing as follows:(values of $dept, $count, $urlink respectively)</p>

<ul>
<li>Accounting, (2),accounting.php</li>
<li>Administrative, (2),administrative.php</li>
<li>Engineering, (2), engineering.php</li>
<li>Food and Beverage, (11), food-and-beverage.php</li>
<li>Hospitality, (16), hospitality.php</li>
<li>Information System, (2), information-system.php  </li>
<li>Warehouse, (4), warehouse.php</li>
</ul>

<p><em>Note: the $urlink above is giving the correct data. It's changing and correspond to the dept but when use in "iframe" always point to accounting.php.</em></p>

<p>How can I pass the $urlink or $row[2] to "iframe" as its url so it can self generate the url of each "iframe"? (total of 7 iframes with different url)</p>

<p>Thanks in advance,</p>