The javascript typically goes between the <head> tags at the top of the page.
Here is a basic db connection class
[PHP]<?
class MyOps {
/* Global Variables */
var $conn = "localhost";
var $user = "db_username";
var $pass = "password";
var $db = "database_name";
/*****************dbconnect()***************************
* dbconnect() will remotely connect to a database *
* with a set of specified arguments. *
* *
* @conn = IP Address of the remote/local database *
* @user = DB Username *
* @pass = DB Password *
* @db = DB Name *
* *
*******************************************************/
function dbconnect() {
$link = mysql_connect($this->conn, $this->user, $this->pass, $this->db) or die("Could not connect : " . mysql_error());
$db_select = mysql_select_db($this->db) or die("error");
return $link;
}
}
?>[/PHP]
Then you import this file and use it like this in other php files that connect to the database
[PHP]
include ("db_scripts/dbconnect.php");
$dbops = New MyOps;
$link = $dbops->dbconnect();[/PHP]
Your overall page will look something like this
==============================start page
<?
//database connection
//query table names
//make a string of table names like this
$list = "<option value='a'>a</option><option value='b'>b</option>";
?>
<html>
(javascript validation)
<form>
<select><?php echo $list; ?></select>
</form>
</html>
==============================end page