RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting

php drop down menu to search multiple sql tables

Join Date: Jul 2004
Location: Arizona State University
Posts: 56
Reputation: bwest is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 1
bwest's Avatar
bwest bwest is offline Offline
Junior Poster in Training

Re: php drop down menu to search multiple sql tables

  #6  
Jul 28th, 2005
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
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:24 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC