Showing all results
Posted: Wed Jan 23, 2008 3:05 pm
I have a code where it takes all results from an employment table and puts them into html tables. Im using java to make it where you click on the title and the rest of it shows up. my problem is when it supposed to echo all the results, it picks the newest one only, instead of sorting and showing all of them. once again im lost, most of the code is in php, but i am inculding the java as well, ill post it in the php part for now (sorry if im not supposed to i dont know)
Code: Select all
<?php
ob_start();
session_start();
//includes
require('configstaff.php');
include('pageedit/conf.php');
include('pageedit/functions.php');
//open databse connection
$connection = mysql_connect($host, $user, $pass) or die ('Unable to connect');
//select database
mysql_select_db($db) or die ('Unable to select database!');
// generate and execute query
$query = "SELECT department, title, description, job FROM employment ORDER BY end";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// get resulset as object
$row = mysql_fetch_object($result);
//print details
if ($row)
{
$dept = $row->department;
$title = $row->title;
$desc = $row->description;
$job = $row->job;
}
?>
<!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>
<style type="text/css">
<!--
div{width:100px; font-family:arial; font-size:14px; color:#000000;}
span{width:100px; visibility:visible;}
//-->
</style>
<script type="text/javascript">
<!--
function clearcell()
{
document.getElementById("information").innerHTML ='<div> *</div>';
}
function description()
{
document.getElementById("information").innerHTML ='<div><?php echo "Description: " . $desc . "<br>"; ?>
<?php echo "Job: " . $job . ""; ?></div>';
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body onload="clearcell();">
<?php if ($title != '')
{
?>
<table><tr><td>
<?php echo "Department: " . $dept . "<br>"; ?>
</td></tr><tr><td>
Title: <a href=javascript:description()><span onclick=this.style.visibility='visible'><?php echo "" . $title . ""; ?></span></a><br>
</td></tr><tr><td>
<div id="information"></div>
</td></tr></table>
<?php
}else{
echo "There are no availablilities right now!";
}
?>