JavaScript and PHP on dropdown menu and MySQL

bigcougar

New Member
My obvious problem is the lack of knowledge of PHP and JavaScript.

I have this page:
http://www.troutsalmonchar.com/ART_BC_LKS_Horseshoe.php

The map is used to generate a filtering string for the drop down menu below it ("SF", "CE", "EE", "SC", "UK"..)

The drop down is created in PHP and is populated with data from a table that contains
ID | Stream_Name | Filter | URL

Do you have any sample scripts that can.

1) Filter the DropDown menu by its third field (e.g. WHERE Filter="SF"..) and refresh its contents.

2) Open the selected page. It's URL is in the URL field of the table

Any ideas as well as details will be greatly appreciated.
I looked at a few examples but for now it is hard to make sense of them.
 

bigcougar

New Member
I picked up a couple of books - PHP and AJAX but am still struggling

The question below is probably very basic. The code that I run produces an error and some of you may be able to see it right away.

I have a JavaScript function LoadList(area) which has to pass the parameter (area) to a PHP file called return_ComboRec.php

What I am trying to do is filter a table on the server based on the parameter (area)

I have the script generating the request; it works fine. My possible errors are in forming the url and the php file itself.

Code:
<script type="text/javascript">

	function LoadList(area) {
	createRequest();
	var url="return_ComboRec.php?area="+'area';    (POSSIBLY WRONG???)
 	request.open("GET",url,true);
	request.onreadystatechange=updatePage;
	request.send(null); 
}
</script>
My return_ComboRec.php is as follows:

Code:
<?php
$link = mysql_connect('server', 'user', 'password'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
if(!mysql_select_db(database))
    die ("Error selecting db:".mysql_error());
$area = $_REQUEST['area'];   (POSSIBLY WRONG????)
$result=@mysql_query("SELECT ID, W_Name from Streams_Lakes WHERE W_Country=$area");

if (!$result)
	die("Error retrieving customer from database.");
while ($row=mysql_fetch_array($result)) {
	echo $row["ID"]."\n".
		$row["W_Name"];
}


?>
Connection to the database is fine (I plug in my actual user, password, server and database and it works OK)
 
Top