RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 22541 | Replies: 14
Reply
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

  #11  
Jul 28th, 2005
There really is almost all the code here in this thread that you would need. You just will need to implement your html and do the query. Besides that, the stuff above will be good for most of your project. As far as your connection goes and that fatal error. You might want to make sure you have properly set up the database. Sometimes the connection isnt "localhost" but is something else so check with your host. There could be about two dozen reasons why you cant connect but once you do just come back to this form because there's lots of good code here.

Good luck
Reply With Quote  
Join Date: Jul 2007
Posts: 4
Reputation: zianchan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zianchan zianchan is offline Offline
Newbie Poster

Re: php drop down menu to search multiple sql tables

  #12  
Jul 26th, 2007
Im having problem with my php and connect to multiple database. I use MySQL. I have index.php, process.php, search.php and dbconnect.php..When I try to run it just do nothing. just 'page error'..I don't know where the mistakes come from..

-----------------------------------------------------
I don't know exactly the common@basic page for process.php, and dbconnect.php..Help me..
Reply With Quote  
Join Date: Jul 2007
Posts: 4
Reputation: zianchan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zianchan zianchan is offline Offline
Newbie Poster

Re: php drop down menu to search multiple sql tables

  #13  
Jul 26th, 2007
Can You evaluate my project 'theses online' coding?

index.php

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>

<body>
<form name="thisForm" method="POST" action="process.php">
<table width="1015" border="0">
<tr>
<td colspan="4"><div align="center"><img src="img/banner1.jpg" width="732" height="102" /></div></td>
</tr>
<tr>
<td width="100"> <b>Home </b> </td>
<td width="357">&nbsp;</td>
<td width="293">&nbsp;</td>
<td width="247">&nbsp;</td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">
<label>Words:
<input type="text" name="words" size = "30"/>
</label>
</div></td>
<td><div align="right">
<label>Search Type
<select name="search_type" size="1">
<option value="1" selected="selected">Penyelia</option>
<option value="2">Nama Pelajar</option>
<option value="3">Program</option>
</select>
</label>
</div></td>
<td><label> </label>

<div align="justify">
<input type="button" name="search_type" value="Search" onclick = "validate()"/>
</div></td>
</tr>
</table>
</form>
</body>
</html>

-----------------------------------------------------
process.php

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>

<body>
<?php

echo_$POST['words'];
echo_$POST['search_type'];

//The name of these post variables is the same as the name
//of the elements that were in the form

?>


</body>
</html>
------------------------------------------------
dbconnect.php

<?php
class MyOps {

/* Global Variables */

var $conn = "localhost";
var $user = "root";
var $pass = "";
var $db = "tesis";


/*****************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;

}

}

?>

---------------------------------------------------

search.php



<?php

//database connection
include ("db_scripts/dbconnect.php");

$dbops = New MyOps;
$link = $dbops->dbconnect();

//query table name

mysql_select_db("tesis", $link);
$result = mysql_query("SELECT pelajar.penyelia, pelajar.nama, projek.tajuk_projek FROM pelajar, projek
WHERE pelajar.no_matriks= projek.no_matrik");
while($row = mysql_fetch_array($result))

{
echo $row['Hit Count'] . " " . $row['Scan Term'];
echo "<br />";
}

//make a string of table names like this

<select name="search_type">

$list = "<option value='1'>Penyelia</option><option value='2'>Nama Pelajar</option>
<option value='3'>Program</option>";

<option>Penyelia</option>
<option>Nama Pelajar</option>
<option >Program</option>

</select>
?>

<html>
<head>
<SCRIPT LANGUAGE="javascript">

function validate() {

fm = document.thisForm

//use validation here to make sure the user entered
//the information correctly

fm.submit()
}
</SCRIPT>

</head>

<body>

(javascript validation)

<form name="thisForm" method="POST" action="process.php">
<table width="1015" border="0">
<tr>
<td colspan="4"><div align="center"><img src="img/banner1.jpg" width="732" height="102" /></div>
</td>
</tr>
<tr>
<td width="100"> <b>Home </b> </td>
<td width="357">&nbsp;</td>
<td width="293">&nbsp;</td>
<td width="247">&nbsp;</td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">
<label>Words:
<input type="text" name="words" size = "30"/>
</label>
</div></td>
<td><div align="right">
<label>Search Type
<select name="search_type" size="1">
<option value="1" selected="selected">Penyelia</option>
<option value="2">Nama Pelajar</option>
<option value="3">Program</option>
</select>
</label>
</div></td>
<td><label> </label>

<div align="justify">
<input type="button" name="search_type" value="Search" onclick = "validate()"/>
</div></td>
</tr>
</table>

</form>

<form>
<?php echo $list?>;
</form>

</body>
</html>

------------------------
Sorry im just learn php and i still have much trouble in understanding coding..For search.php file, i need your advice..What i mean is i want for column scan term it will show "penyelia", "nama pelajar", and "tajuk_projek" and for hit count column i want it count for how many "tajuk_projek" that available in database. My system will look like library online..When we search book, there are list available and hit count too.where should i put coding for hit counter??
Reply With Quote  
Join Date: Jul 2007
Posts: 4
Reputation: zianchan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zianchan zianchan is offline Offline
Newbie Poster

Re: php drop down menu to search multiple sql tables

  #14  
Jul 26th, 2007
this happen when i submit search button

Parse error: parse error in c:\phpdev\www\projecttheses\process.php on line 11

the mistakes in here:echo_$POST['words'];
Reply With Quote  
Join Date: Jul 2007
Posts: 4
Reputation: zianchan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
zianchan zianchan is offline Offline
Newbie Poster

Re: php drop down menu to search multiple sql tables

  #15  
Jul 26th, 2007
Im sorry this is my coding for search.php



<?php

//database connection
include ("db_scripts/dbconnect.php");

$dbops = New MyOps;
$link = $dbops->dbconnect();

//query table name

mysql_select_db("tesis", $link);
$result = mysql_query("SELECT pelajar.penyelia, pelajar.nama, projek.tajuk_projek FROM pelajar, projek
WHERE pelajar.no_matriks= projek.no_matrik");
while($row = mysql_fetch_array($result))

echo "<table border='1'>
<tr>
<th>Hit Count</th>
<th>Scan Term</th>
</tr>";while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Hit Count'] . "</td>";
echo "<td>" . $row['Scan Term'] . "</td>";
echo "</tr>";
}
echo "</table>";

//make a string of table names like this

<select name="search_type">

$list = "<option value='1'>Penyelia</option><option value='2'>Nama Pelajar</option>
<option value='3'>Program</option>";

<option>Penyelia</option>
<option>Nama Pelajar</option>
<option >Program</option>

</select>
?>

<html>
<head>
<SCRIPT LANGUAGE="javascript">

function validate() {

fm = document.thisForm

//use validation here to make sure the user entered
//the information correctly

fm.submit()
}
</SCRIPT>

</head>

<body>

(javascript validation)

<form name="thisForm" method="POST" action="process.php">
<table width="1015" border="0">
<tr>
<td colspan="4"><div align="center"><img src="img/banner1.jpg" width="732" height="102" /></div>
</td>
</tr>
<tr>
<td width="100"> <b>Home </b> </td>
<td width="357">&nbsp;</td>
<td width="293">&nbsp;</td>
<td width="247">&nbsp;</td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right">
<label>Words:
<input type="text" name="words" size = "30"/>
</label>
</div></td>
<td><div align="right">
<label>Search Type
<select name="search_type" size="1">
<option value="1" selected="selected">Penyelia</option>
<option value="2">Nama Pelajar</option>
<option value="3">Program</option>
</select>
</label>
</div></td>
<td><label> </label>

<div align="justify">
<input type="button" name="search_type" value="Search" onclick = "validate()"/>
</div></td>
</tr>
</table>

</form>

<form>
<?php echo $list?>;
</form>

</body>
</html>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:48 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