hello
i have a list of employees and the name of the employee passes their id in the url of a popup page. i then want to get this id from the url in the popup page, query mysql to get the value of another column in the same table and row as the specified id. the value is a file name that then points to an image of that employee. i'm going wrong somewhere, can anyone help please? here is my code so far:
main page:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>
<a href="popuptest.php?employee_id=1" onclick="NewWindow(this.href,'name','480','400','no');return false;">employee one</a>
<a href="popuptest.php?employee_id=2" onclick="NewWindow(this.href,'name','480','400','no');return false;">employee two</a>
popup page:
<?php
require_once ('mysql_connect.php');
$employee_id=$_GET['employee_id'];
$query = "SELECT employee_filename FROM staff WHERE employee_id=".$employee_id;
$result = @($query);
if ($result) {
echo "<img src=\"images/$result\">";
} else {
echo "no employee data";
}
?>
i checked my connection and it is working fine as i can get info from the database, but i cannot get the image to display. i tried with employee.jpg as the value in the database and also with employee and then adding the .jpg in the actual php - not sure whether you are alowed filename.jpg as a value in mysql field.
can anyone help please? many thanks in advance.