Greetings all,
I have a question. I have a webpage that displays a list of surnames in a table.
What I would like to do is the following:
After the user comes to the page for a list of displayed surnames, I would like to be able for the user to click on the surname and have a popup window come up and display with email address of the person who submitted the surname as well as the full list of surnames submitted by that same person using that email address.
How tricky will this be?
Here is my code for the page that displays the surname (currently linked by the email address) for this database.
<?php
include("../../includes/db.inc");
//Set the number of columns for the page
$columns = 5;
$dbh=@mysql_connect ("$dbhost", "$dbuser", "$dbpass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("$dbname");
$qrySurname__letter = "%";
// Output letters as links: (Ascii range from 65 to 90 are letters A to Z!)
// Trying to do this automatically without having to resort to hand coding // of every single link
for($x=65;$x<=90;$x++)
{
if ($x==ord($subsel)) echo "<b>".chr($x)."</b>";
else
echo "<a href=\"surnametest4.php?letter=".chr($x)."\">".chr($x)."</a> ";
}
$letter = $_GET["letter"];
if (isset($letter))
{
$qrySurname = "SELECT * FROM surnames WHERE nm_surname LIKE '$letter%' ORDER BY nm_surname";
} else {
$qrySurname = "SELECT * FROM surnames ORDER BY nm_surname";
}
$result = mysql_query($qrySurname);
//Need to know the number of rows, so use this line
$num_rows = mysql_num_rows($result);
//Set a new variable called $rows
$rows = ceil($num_rows / $columns);
//For this vertical display, need to run another loop, which will populate an array with our values
while($row = mysql_fetch_array($result)) {
$email[] = $row['nm_email'];
$surname[] = $row['nm_surname'];
$valid_em[] = $row['valid_em'];
$valid_mem[] = $row['valid_mem'];
}
echo "<TABLE BORDER=1 cellpadding=5 align=center>\n";
/*This is the section that I am sure I need to modify the current <A HREF="?">.$surname...I want to keep the surname as the link and when clicked will pull up the window and pull the $email address of the submitter and well as the rest of the $surnames that match that email.
*/
for ($i = 0; $i < $rows; $i++) {
echo "<tr>";
for ($j = 0; $j <$columns; $j++) {
if(isset($email[$i + ($j * $rows)])) {
echo "<td><li> <A HREF=\"mailto:".$email[$i + ($j * $rows)]."\">".$surname[$i + ($j * $rows)]."</a></li> ";
}
if (strcmp("No", $valid_em[$i + ($j * $rows)])==0) {
echo "<img width=16 height=15 align=absmiddle src=\"exclamation.jpg\" border=0> ";
}
if (strcmp("Yes", $valid_mem[$i + ($j * $rows)])==0) {
echo "<img align=absmiddle src=\"mem.jpg\" border=0></td>";
}
}
echo "</tr>";
}
echo "</table>";
?>
Thanks!