need correct position
Posted: Thu Jan 31, 2008 10:28 am
I've been working on this a while
i have a code where if you click on a title it will show up the desc and stuff, and i got it to work with a few different codes, but the problem i have now is not it showing up the right stuff, but showing it up in the right place. i have 3 different titles, and i need descriptions to show up under each one according to the title. its all in mysql, and im using php js bla bla bla 
heres my code
and heres an example of what it does so you can see better what im saying.
http://cyril.ulmb.com/emp/employment.php
click on the titles, and im sorry about the bad words. :/
i have the content pulled up showing up in a div, and the div is technically reproduced with every field in the db (you can tell b/c the * under each title is default for the div), but the content only shows up in the first produced div no matter what.
heres my code
Code: Select all
<?php
ob_start();
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Our wonderful AJAX page!</title>
<script language="javascript" type="text/javascript">
function getPage(page){
var xmlhttp=false; //Clear our fetching variable
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
var file = 'text.php?page='; //This is the path to the file we just finished making *
xmlhttp.open('GET', file + page, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
var content = xmlhttp.responseText; //The content data which has been retrieved ***
if( content ){ //Make sure there is something in the content variable
document.getElementById('content').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
}
}
}
xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}
</script>
</head>
<body>
<?php
include('../pageedit/conf.php');
$connection = mysql_connect($host, $user, $pass) or die ('Unable to connect');
mysql_select_db($db) or die ('Unable to select database!');
$query = "SELECT department, title, description, job FROM employment";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
while($row = mysql_fetch_object($result))
{
$title = $row->title;
$dept = $row->department;
?>
<font color="#000000"><a href="javascript:getPage('<?php echo "" . $title . ""; ?>')"><?php echo "" . $title . ""; ?></a></font>
<div id="content">
<p>*</p>
</div>
<?
}
?>
</body>
</html>http://cyril.ulmb.com/emp/employment.php
click on the titles, and im sorry about the bad words. :/
i have the content pulled up showing up in a div, and the div is technically reproduced with every field in the db (you can tell b/c the * under each title is default for the div), but the content only shows up in the first produced div no matter what.