Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 22541 | Replies: 14
![]() |
•
•
Join Date: Jul 2004
Location: Arizona State University
Posts: 56
Reputation:
Rep Power: 5
Solved Threads: 1
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
Good luck
•
•
Join Date: Jul 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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..
-----------------------------------------------------
I don't know exactly the common@basic page for process.php, and dbconnect.php..Help me..
•
•
Join Date: Jul 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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??
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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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??
•
•
Join Date: Jul 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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>
<?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"> </td>
<td width="293"> </td>
<td width="247"> </td>
</tr>
<tr>
<td> <b>Admin</b></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><b>About Us</b> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </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>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode