Hello everyone! :) Could you please help me? I am still a noob and I'm having a hard time about displaying selected values from mysql database into popup window? This is my code where user can see the table of the electoral officials:

-----CUT-----

<div id="page">
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
<a href="#" name="bio" onclick="popup('popUpDiv')">Close</a>
</div>

<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'") 
or die(mysql_error());  

echo "<center><table id='tables' class='sortable'>";
echo "<tr><th>Secretary:</th></tr>";
while($row = mysql_fetch_array( $result )) {               
echo "<tr>";
$row['c_ID'];
echo '<td>' . $row['c_fname'] . ' ' . $row['c_lname'] .'</td>';
echo '<td><a href="cand.php?ID=' . $row['c_ID'] .'" name="bio" onclick="popup("popUpDiv")">View Profile</a></td>';
echo"</tr>";
}
echo"</table></center>";  
}
?>

-----CUT-----

What I want to do is when the user clicks on the "View Profile", a pop up window opens with the information of the selected candidate that stored in the content field of the database. Do you have any idea? I hope you can help me with this. Any help would be greatly appreciated.

Member Avatar for diafol

Few ways you can do this.
My faves:

1) Either get ALL the info from the DB on page load and place it into a json object, so you never have to mess with the server/DB again - js populates the popup
2) Use Ajax to dynamically populate the popup

JS required either way for these solutions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.