Forum Moderators: open
<html>
<head>
<title>Project Manager</title>
<link href="style_regular_page.css" rel="stylesheet" type="text/css" />
<script src="index.js"></script>
</head>
<body>
<div id="txtHint">l;jlkj;;;lkl;skjdl;fkj</div></p>
<?php
include( 'conn_inc.php' );
include( 'comm_func.php' );
//used to fill the client dropdown menu
$doworkson = "SELECT * FROM client ORDER BY last_name ASC";
$q=$_GET["q"];
$doworkson2 = "SELECT * FROM client WHERE id = '".$q."'";;
//this is the query used to access the client info
$show_client_lastName=mysql_query($doworkson,$connect);
//this determines the number of clients in the database
$num_rows_client = mysql_num_rows($show_client_lastName);
//this shows all the info from the client
$show_client_info=mysql_query($doworkson2,$connect);
div_id('header');
header1();
today();
title("This is the main menu");
end_div();
div_id('body');
div_id('left');
nav_bar();
end_div();
div_id('content');
echo "<p>View Client Information :</p>";
echo "<form name=\"view clients\">";
echo "<select name=\"client\" onChange=\"viewClient(this.value)\">";
if ($num_rows_client==0){
echo "<option> Sorry, but there are no results to display</option>";
} else {
while ($client= mysql_fetch_array($show_client_lastName)){
$client_lastName=$client["last_name"];
echo "<option value=\"".$client_lastName."\">".$client_lastName.", ".$client["first_name"]."</option>";
}
}
echo "</select>";
if ($num_rows_client!=0){
echo "<table border=\"1\">";
echo "<th>First Name</th><th>Last Name</th><th>Home number</th><th>Office number</th>";
while ($client_info=mysql_fetch_array($show_client_info)){
echo "<tr>";
echo "<td>".$client_info['first_name']."</td>";
echo "<td>".$client_info['last_name']."</td>";
echo "<td>".$client_info['home']."</td>";
echo "<td>".$client_info['office']."</td>";
echo "</tr>";
}
echo "</table>";
}
mysql_close($connect);
end_div();
end_div();
div_id('footer');
footer();
end_div();
?>
</body>
</html>
and this is the "AJAX" part of it
var xmlHttp
function viewClient(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="index.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 ¦¦ xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
As you can see, for testing purposes i've placed the 'txtHint' div on top for testing purposes with some random text. I cant really understand the output the first thing I get is "Notice: Undefined index: q in C:\wamp\www\testing folder\project_manger\index.php on line 16". the second second sign I get is, the dropdown menu goes back the the first value in the dropdown. The third thing I get is a duplicate site. I was wondering if anyone could help me find out how i can make it work