SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE

SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE

pls help me....in this i want to search books from the database...but it shows some errors. Error is Notice: Undefined variable: searching in C:\xampp\htdocs\project\opac1.php on line 10

  HERE IS MY CODE

my html page is

<html>
<body>
<form name="search" method="post" action="opac1.php">
                    <div align="center"></div>
                   <div align="center"></div>
                  <div align="center">
                    <table width="300" border="0">
                      <tr>
                        <td width="81">Author</td>
                        <td width="209">
                          <label for="textfield2"></label>
                          <input type="text" name="find" id="textfield2" />
                        </td>
                      </tr>
                      <tr>
                        <td>Title</td>
                        <td>
                          <label for="textfield3"></label>
                          <input type="text" name="find" id="textfield3" />
                        </td>
                      </tr>
                      <tr>
                        <td>Accession no</td>
                        <td>
                          <label for="textfield4"></label>
                          <input type="number" name="find" id="textfield4" />
                        </td>
                      </tr>
                      <tr>
                        <td>Edition</td>
                        <td>
                          <label for="textfield5"></label>
                          <input type="number" name="find" id="textfield5" />
                        </td>
                      </tr>
                      <tr>
                        <td>Publisher</td>
                        <td>
                          <label for="textfield6"></label>
                          <input type="text" name="find" id="textfield6" />
                        </td>
                      </tr>
                    </table>
                    <table width="300" border="0">
                      <tr>
                        <td width="81">Year</td>
                        <td width="209">
                          <label for="textfield7"></label>
                          <input type="number" name="find" id="textfield7" />
                        </td>
                      </tr>
                    </table>
<p> </p>
                   <input type="hidden" name="searching" value="yes" />
                               <input type="submit" name="search" value="Search" />
                      <input type="submit" name="button2" value="Clear" />
                      <img src="images/images (9).jpg" width="104" height="104" longdesc="images/images (9).jpg" />
                    </form>
</body>
</html>

php page is:
<?php
  if ($searching =="yes"){
  echo "<h3>Search Results</h3><p>";
  if ($find == ""){
  echo "<p>Please Enter a search term";
  exit;
  }

 // Otherwise we connect to our Database 
 $con = mysql_connect("localhost");
if (!$con)
  {
  mysql_select_db("test") or die('Could not connect: ' . mysql_error());
  }

 // We preform a bit of filtering 
 $find = strtoupper($find); 
 $find = strip_tags($find); 
 $find = trim ($find); 

 //Now we search for our search term, in the field the user specified 
 $data = mysql_query("SELECT * FROM book WHERE upper($field) LIKE'%$find%'"); 

 //And we display the results 
 while($result = mysql_fetch_array( $data )) 
 { 
 echo $result['book id']; 
 echo " "; 
 echo $result['access no']; 
 echo "<br>"; 
 echo $result['author']; 
 echo "<br>"; 
 echo $result['title']; 
 echo " "; 
 echo $result['publisher']; 
 echo "<br>"; 
 echo $result['year']; 
 echo "<br>"; 
 echo "<br>"; 
 } 

 //This counts the number or results - and if there wasn't any it gives them a little message explaining that 
 $anymatches=mysql_num_rows($data); 
 if ($anymatches == 0) 
 { 
 echo "Sorry, but we can not find an entry to match your query<br><br>"; 
 } 
 } 
 ?>

thank you for helping me out.

View Answers

August 20, 2011 at 10:29 PM

    you just write a code look like this.
    if ($ _POST['searching'] =="yes"){
      echo "<h3>Search Results</h3><p>";
      if ($ _POST['find'] == ""){
      echo "<p>Please Enter a search term";

    and
    you have written each input type as number which is incorrect u just write input type 
as text or whatever u want..

Ads









Related Tutorials/Questions & Answers:
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE  pls help me....in this i want to search books from the database...\htdocs\project\opac1.php on line 10 HERE IS MY CODE my html page is <
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
Advertisements
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
display data from database on selecting option of dropdownlist
display data from database on selecting option of dropdownlist   Sir I want to display data from database by just selecting option of dropdown list... is that to display image from database in a grid format or in a fixed column and row
Display Data from Database in JSP
; <html> <head> <title>display data from...;To display all the data from the table click here...</h2></TD>..., to show data from the database click on the link that calls another .jsp file named
jfreechart display from access database data.
jfreechart display from access database data.  I have made a database... to retrieve the data from the access database using prepared statement and then display the bar graph using jfreechart API .This whole retrieval and display of chart
Display Data from Database in JSP
Display Data from Database in JSP   ... and run. This page has a link, to show data from the database click... and execute query to display data from the specified table.  Before
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file..." contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page...+",'"+email+"')"); out.println("Data is successfully inserted into database
How to display data from database in a TableView
How to display data from database in a TableView  I need to populate a TableView (JavaFx) with database items. I designed the TableView in JavaFx... at this. The classes: This is the Class that creates the database data object: import
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
Display Data from Database in JSF Application
Display Data from Database in JSF Application  ... data from database in JSF application. Developing JSF  Application In this section, we are going to display data from database in JSF based web
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
how to display data into textboxes which is retrieved from the database
how to display data into textboxes which is retrieved from the database  I would like to know how to display data into textboxes which is retrieved from database in jsf. could you please provide a small example of how to do
jsp code for display of data from database and snap shot of the output
jsp code for display of data from database and snap shot of the output  i am using JSP.i want to insert data into database and also want to display the things i have entered in the same page inside the corresponding fields
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... server, and implement the needed data objects in a database server. The clients... a employee's name from a comboBox and the jtable will be filled with all
Dynamic retrieval od data from database and display it in the table at jsp
Dynamic retrieval od data from database and display it in the table at jsp ... the data from the mysql database... pls its urgent.. help me frnds....   Here is a jsp code that retrieves the data from the database and display
how to display data from database according to entered value in search field
how to display data from database according to entered value in search...; <%@page import="java.sql.*"%> <%@page contentType="text/html...(); System.out.println("Disconnected from database"); } catch (Exception e
How to display data from database in a TableView via Hibernate
How to display data from database in a TableView via Hibernate  I need to populate a TableView (JavaFx) with database items. I designed the TableView... at this. The classes: This is the Class that creates the database data object
MySql Databse query to fetch results from database and display it in HTML File
MySql Databse query to fetch results from database and display it in HTML File  Hi. I have a field in database named stages. its datatype is varchar... to retrieve these data from the field table. Actually they are separated by comma
Display error message if data is already inserted in database
Display error message if data is already inserted in database   Display error message if data is already inserted in database Pls help me Thanks
How To Display both image and data into Swing JTable which is retrieved from ms access database
How To Display both image and data into Swing JTable which is retrieved from ms access database  So far this is my code how can i display both image and data from database.. while (rs.next()) { Vector row = new Vector(columns
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying on the web page. My application is in Java/JSP. How to retrieve and display image
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
display date to jsp from database
display date to jsp from database   display date to jsp from database to calender if the start date and end date is available than calender date... not available in database field than show in green color and clickable. NOTE :- Date
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting... have to display the Nodename and packageno. i.e.,select nodename,packageno from... DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.  The code for retrieving data from database into Drop Down List. <% DataSource data = new

Ads