Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sibymarysam
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
1 Answer(s)      3 years and 4 months ago
Posted in : PHP


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.


Advertisement
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..


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
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
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
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
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
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 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 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
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
how to display database data in jsf page - Java Server Faces Questions
how to display database data in jsf page  Hi, i created tables in database,now i need to display the tables in jsf page.Means i have to get the deatils from database and i need to display in jsf.Please tell me the procedure
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
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
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
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
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf  Hi, 1.how to get the data from database. 2.how to display the database... and to display the data from database in jsf visit to : http://www.roseindia.net/jsf
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
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
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
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
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
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
Advertisements
 

 

 

DMCA.com