
March 26th, 2000, 11:40 AM
|
|
Junior Member
|
|
Join Date: Mar 2000
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I am trying to serach a record from mysql table with php query.
following is the code.
when we use mysql_select_db();
what should be the datbase name.
when we use mysql_quer() we give table name.
how this table name is different from the databse name<html>
<head>
<title> SAVDHAN.COM SEARCH </title>
</head>
<body bgcolor="#C0C0C0" topmargin="40" leftmargin="50">
<h1 ALIGN=CENTRE><font color="#FF0000">SEARCH ON INDIVIDUAL NAME</font> </h1>
<p> </p>
<hr>
<hr>
<?php
/* Check that Fst name or sr name is inserted for serach */
if ($submit)
{
if (!$Fst_name & !$Sr_name)
{
$error = "Sorry! Enter the LASt NAME or FIRST NAME to get the serch Result!";
}
else
{
// process form
//echo "Thank You!";
// Connect to MySQL database and open the required table
$db = mysql_connect("localhost", "root");
mysql_select_db("test1",$db);
$result = mysql_query ("SELECT * Amount FROM test1 WHERE First_name = "Fst_name",$db);
if ($myrow = mysql_fetch_array($result))
{
echo "<table border=1>n";
do {
// list the search details if it is an indiviual
if (!$myrow["Comp_name"])
{
echo "<tr><td>Name</td><td>Bank Name</td><td>Amount</td></tr>n";
printf("<tr><td>%s %s</td><td>%s</td><td>%s</td></tr>n", $myrow["First_name"], $myrow["Sur_name"], $myrow["Bank_name"], $myrow["Amount"]);
}
} while ($myrow = mysql_fetch_array($result));
echo "</table>n";]=74
}
}
}
?>
<form method="POST" action="<?php echo php_self ?>">
<p>Last Name <input type="text" size="20"
maxlength="40" name="Sr_name"> </p>
<p>First Name <input type="text" size="20"
maxlength="40" name="Fst_name"></p>
<p><input type="submit" name="indv_search" value="Search"> <input
type="reset" name="indv_rest" value="Reset"></p>
</form>
<p> </p>
<hr>
<hr>
</body>
</html>
|