So Im trying to develop a query where Anyone that knows how to do this with both javascript (onclick event) and a php variable (which should contain the content)
I need it for a organisation list. where all of the names are a hyperlink. Whenever someone click one of the names, an onclick event should make a variable display in a specific table cell underneath it.
When the next organisation is clicked, the first information should disappear and the new organisation record should appear in the same table cell. I hope this is clear?
Im having problems having starting my syntax. This is what I have for list of hyperlinked orgs:
<?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>';
}
?>
and this is what the resulting output is if you click the organisation name
<?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:
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>
<td colspan="3">' . $row['website'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">Local Agency</td>
</tr>
<tr>
<td colspan="3">' . $row['local_agency'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">Contact</td>
</tr>
<tr>
<td colspan="3">' . $row['contact'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">What is it</td>
</tr>
<tr>
<td colspan="3">' . $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">' . $row['who_what_apply'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">How does it work?</td>
</tr>
<tr>
<td colspan="3">' . $row['how_work'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">What are the resource implications?</td>
</tr>
<tr>
<td colspan="3">' . $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">' . $row['how_meet_standards'] .'</td>
</tr>
<tr>
<td class="heading" colspan="3">How widespread is it?</td>
</tr>
<tr>
<td colspan="3">' . $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
}
?>