PDA

View Full Version : Switch Menu PHP Query



tezread
09-29-2006, 02:21 PM
1) Script Title: Switch Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm

3) Describe problem:

I am trying to adapt this approach so that the menu items are listed using a PHP query and when clicking a menu item the records relating to it are displayed. Perhaps this will best be demonstrated through a page on my website:

http://www.mindseyemidlands.co.uk/elearningcourses.php

In my case I would like a list of quality systems to be the 'menu items' and when you click the menu item the details relating to it are 'expanded'.

Here is my PHP query that at present lists the quality systems.



include("connect.php");
$sql = "SELECT quality_name FROM qualityadmin WHERE category ='List A Generic Standards'";
$result = mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
echo '<a href="qualitysystem_summary1_details.php?quality_name='. urlencode($row[0]) .'">'. $row[0] .'</a><br><br>';
}


and here is the resulting query after clicking the chosen quality system



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" fontsize= "18px">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>


How can I incorporate these queries so they function like the switch menu on Dynamic?

Thanks in advance

jscheuer1
09-30-2006, 07:17 AM
PHP cannot be dynamic. It can populate your page with content before it is served to the browser. If you know how to get your content onto the page under normal circumstances (no switch menu script) then simply use PHP to populate both the hidden and visible parts of the menu. That's all you can do. You cannot populate the content 'on the fly' once a choice is made, it has to already be on the page before the script even starts working. This part is just like the script used without PHP.

tezread
10-02-2006, 05:23 PM
use PHP to populate both the hidden and visible parts of the menu.

I see - im not sure what you mean by this though

jscheuer1
10-02-2006, 06:09 PM
I think I may have misunderstood your question. You just need to get them to write out in the form typically used by switch menu - as shown in step 2 on the demo page.

You would get better specific help in the PHP forum on that I think, but, it is just a matter of writing out the type of HTML that the script expects.