I have a table in mysql like this
id fname lname
=============
1 amit gupta
2 sumit rai
3 raj kohli
4 kunal sharma
5 sonu saini
and I have a textbox and a ok button in html form. I want, when we enter 3(id) in the textbox then click ok button then display only data of id 3 i.e. raj kohli. How to do this ? Please help me anyone with an example ?
Thanks

Satyapriya NayakPosted May 20, 2012, 2:32 PM
Try this...
Table
-- phpMyAdmin SQL Dump
-- version 2.10.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 20, 2012 at 06:25 PM
-- Server version: 5.0.45
-- PHP Version: 5.2.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `employee`
--
CREATE TABLE `employee` (
`fname` varchar(255) NOT NULL,
`lname` varchar(255) NOT NULL,
`id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `employee`
--
INSERT INTO `employee` (`fname`, `lname`, `id`) VALUES
('Amit', 'Gupta', 1),
('Kunal', 'Sharma', 2),
('Raj', 'Kohli', 3);
config.php
$host="localhost";
$username="root";
$password="";
$dbname="test";
$con=mysql_connect("$host","$username","$password");
mysql_select_db("$dbname",$con);
?>
search.php
include('config.php');
?>
if($_REQUEST["Submit"]=="Search") {
$sql="select * from employee where fname like '%$_REQUEST[fname]%' OR lname like '%$_REQUEST[fname]%' OR id='$_REQUEST[fname]'";
$sql_row=mysql_query($sql);
$num=@mysql_num_rows($sql_row);
if($num > 0) {
?>
while($sql_res=@mysql_fetch_assoc($sql_row)) {
?>
No Results found
Thanks
If this post helps you mark it as answer
Vineet Kumar SainiPosted May 24, 2012, 1:23 AM
Satyapriya NayakPosted May 24, 2012, 1:10 AM
If this post helps you please mark it as answer
Thanks