I have a query that lists organisations:
<?php
include("connect.php");
$sql = "SELECT quality_name FROM qualityadmin WHERE category ='List A Generic Standards'";
//echo $sql."<br>";
$result = mysql_query($sql) or die(mysql_error());
//echo $result."=result<br>
//";
while($row=mysql_fetch_array($result))
{ // NOTE this one ABOVE the echo
//echo "result found!";
//echo $row[0];
echo '<a href="qualitysystem_summary1_details.php?quality_name='. urlencode($row[0]) .'">'. $row[0] .'</a><br><br>';
//echo $row[1] .'<br>';
}
?>
choosing an organisation gives details about that organisation:
<?php
if (isset($_GET['quality_name'])) {
include ("connect.php");
$course = mysql_real_escape_string($_GET['quality_name']);
$res = "SELECT * FROM qualityadmin WHERE quality_name = '$quality_name'";
$result = mysql_query($res) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
// begin output here:
$dtld = array('http://', 'www.', '.com', '.edu', '.fr', '.org', '.eu', '.us', '.biz', '.net', '.cz', '.it', '.cc', '.ca', '.pdf','.html'); // Add other TLD items as needed
echo '<style type="text/css">
#myTable td {
font-family:arial, helvetica, sans-serif;
font-size: 14px;
}
.heading {
background:#eee;
color: #0000cc;
}
</style>
<table cellpadding="2" cellspacing="0" border="1" id="myTable" width="700px">
<tr>
<td class="heading" colspan="3">Quality Name</td>
</tr>
<tr>
<td colspan="3">' . $row['quality_name'] .'</td>
</tr>
<tr>
<td class="heading" colspan="4">Authority Body</td>
</tr>
<tr>
<td colspan="3">' . $row['authority_body'] . '</td>
</tr>
<tr>
<td class="heading">Address 1</td>
<td class="heading">Address 2</td>
<td class="heading">Town</td>
</tr>
<tr>
<td>' . $row['address1'] . '</td>
<td>' . $row['address2'] . '</td>
<td>' . $row['town'] . '</td>
</tr>
<tr>
<td class="heading">Postcode</td>
<td class="heading">Telephone</td>
<td class="heading">Email</td>
</tr>
<tr>
<td>' . $row['postcode'] . '</td>
<td>' . $row['telephone'] . '</td>
<td>' . $row['email'] . '</td>
</tr>
<tr>
<td class="heading" colspan="3">Website</td>
</tr>
<tr>
<tr>
<td colspan="3"><a href="'. ((strpos($row['website'], 'http://')===false)?'http://':'') . $row['website'] .'" target = "_blank">'. str_replace($dtld, '', $row['website']). '</a></td>
</tr>
<tr>
<td class="heading" colspan="3">Local Agency</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['local_agency'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">Contact</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['contact'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">What is it</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['what_is_it'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">Who and what does it apply to?</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['who_what_apply'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">How does it work?</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['how_work'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">What are the resource implications?</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['resource_implications'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">How do you meet the standards and get assessed?</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['how_meet_standards'] ).'</td>
</tr>
<tr>
<td class="heading" colspan="3">How widespread is it?</td>
</tr>
<tr>
<td colspan="3">' . nl2br( $row['widespread'] ) .'</td>
</tr>
<tr>
<td class="heading" colspan="3">What are the pros and cons?</td>
</tr>
<tr>
<td colspan="3">' . $row['pros_cons'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">What are the benefits?</td>
</tr>
<tr>
<td colspan="3">' . $row['benefits'] .'</td>
</tr>
</table>';
}
} else {
//course name not found
//note: the query may have failed to so maybe check for that.
}
} else {
//no course specified
}
?>
my question is how do i create an approach whereby clicking the organisation results in the query expanding into a table and when clicking another organisation the previous table closes and produces another table etc.
this is my expanding code:
<a href="javascript:void(0);" onclick="return Collapse_Expand();">list of orgs echoed here</a>
<div id="hide_show" style="border:1px solid;display:block;">
This bit will be Collapse/Expand the organisation details when the org name is clicked
</div>
<script language="JavaScript" type="text/javascript">
function Collapse_Expand() {
var hide_show = document.getElementById('hide_show');
if (hide_show.style.display == 'none' ) hide_show.style.display = 'block';
else hide_show.style.display = 'none';
}
</script>
im not sure how best to incorporate my queries to suit the above code
thx in advance