educratsweb@mail.com

+91

📂 Register 🔒 Login
PHP CODE FOR VIEW, SEARCH, EDIT AND DELETE RECORD FROM MYSQL TABLE #EDUCRATSWEB

PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

This is the simple Code Example through which you can insert, Delete, View , Update from MySql Database.

 

Paste this code and save the file as written above. Create a database named test and create a table student as below structure.

 

MySql Table

 

CREATE TABLE `student` (  `roll` int(11) default NULL,  `class` varchar(20) default NULL,  `name` varchar(40) default NULL,  `f_name` varchar(40) default NULL,  `sex` varchar(6) default NULL,  `addr1` varchar(20) default NULL,  `addr2` varchar(20) default NULL,  `addr3` varchar(20) default NULL,  `city` varchar(20) default NULL,  `phone` varchar(12) default NULL,  `email` varchar(100)

default NULL,  `remarks` varchar(40) default NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

 

Index.php [Main or Home Page]

 

 

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Search Student  Record</title>

</head>

<body>

<center><h1><u>Student Database</u></h1></center>

<form name="search" method="post" action="search.php">

<table style=" border:1px solid silver" cellpadding="10px" cellspacing="0px" align="center">

<tr>

<td colspan="3" style="background:#0066FF; color:#FFFFFF; font-size:20px">Search</td></tr>

<tr>

<td>Enter Search Keyword</td>

<td><input type="text" name="search" size="40" /></td>

<td><input type="submit" value="Search" /></td>

</tr>

<tr>

<td colspan="3">&nbsp;</td></tr>

<tr bgcolor="#CCCCCC">

<th><a href="add.php">Add Record</a></th>

<th><a href="del.php">Delete Record</a></th>

<th><a href="del.php">Update Record</a></th>

</tr>

</table>

</form>

</body>

</html>

 

 

 

Search.php

 

<?

mysql_connect("localhost");

mysql_select_db("test") or die("database could not connect ");

?>

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Search Student  Record</title>

</head>

<body>

<center><h1><u>Student Database</u></h1></center>

<form name="search" method="post" action="search.php">

<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0">

<tr>

<td colspan="3" style="background:#0066FF; color:#FFFFFF; font-size:20px">Search</td></tr>

<tr>

<td>Enter Search Keyword</td>

<td><input type="text" name="search" size="40" /></td>

<td><input type="submit" value="Search" /></td>

</tr>

<tr bgcolor="#666666" style="color:#FFFFFF">

<td>Roll & class</td>

<td>Name & Father's Name</td>

<td>&nbsp;</td>

 

<?

$search=$_POST["search"];

$flag=0;

$query="select * from student where  name like '%$search%' ";

$result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

$flag=1;

echo "<tr ><td>",$row[0],", ",$row[1],"</td><td><a href='view.php?roll=",$row[0],"'>",$row[2],", ",$row[3],"</a></td><td><a href='edit.php?roll=",$row[0],"'>Edit</a> | <a href='del.php?roll=",$row[0],"'>Delete</a></td></tr>";

 

}

if($flag==0)

echo "<tr><td colspan='3' align='center' style='color:red'>Record not found</td></tr>";

 

?>

<tr>

<td colspan="3">&nbsp;</td></tr>

<tr bgcolor="#CCCCCC">

<th colspan="3" align="right"><a href="add.php">Add Record</a></th>

</tr>

</table>

</form>

</body>

</html>

 

 

View.php

 

<?

mysql_connect("localhost");

mysql_select_db("test") or die("database could not connect ");

?>

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>View Student  Record</title>

</head>

<body>

<center><h1><u>Student Database</u></h1></center>

<?

$roll=$_GET["roll"];

$query="select * from student where roll='$roll'";

$result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

 

?>

<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="1">

<tr>

<td colspan="4" style="background:#0066FF; color:#FFFFFF; font-size:20px">VIEW STUDENT DATABASE</td></tr>

<tr>

<td> Roll Number</td><td><? echo $row[0];?></td>

<td> Class</td><td><? echo $row[1];?></td>

</tr>

<tr>

<td> Name of Student</td><td><? echo $row[2];?></td>

<td> Father's Name</td><td><? echo $row[3];?></td>

</tr>

<tr>

<td>Sex</td><td><? echo $row[4];?></td>

<td>Address1</td><td><? echo $row[5];?></td></tr>

<tr>

<td>Address2</td><td><? echo $row[6];?></td>

<td>Address3</td><td><? echo $row[7];?></td></tr>

<tr>

<td>City</td><td><? echo $row[8];?></td>

<td>Phone</td><td><? echo $row[9];?></td></tr>

<tr>

<td>Email</td><td><? echo $row[10];?></td>

<td>Remarks</td><td><? echo $row[11];?></td></tr>

<tr>

 

</table>

<?

}

?>

<p align="center"><a href="index.php">Go Back to Home</a></p>

</body>

</html>

 

 

 

Add.php

 

 

<?

mysql_connect("localhost");

mysql_select_db("test") or die("database could not connect ");

?>

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Add Student  Record</title>

</head>

<body>

<center>

  <h1><u>Student Database</u></h1>

</center>

<?

if($_POST["do"]=="store")

{

$roll=$_POST["roll"];

$class=$_POST["class"];

$name=$_POST["name"];

$fname=$_POST["fname"];

$sex=$_POST["sex"];

$addr1=$_POST["addr1"];

$addr2=$_POST["addr2"];

$addr3=$_POST["addr3"];

$city=$_POST["city"];

$phone=$_POST["phone"];

$email=$_POST["email"];

$remarks=$_POST["remarks"];

$query="insert into student value($roll,'$class','$name','$fname','$sex','$addr1','$addr2','$addr3','$city','$phone','$email','$remarks')";

mysql_query($query);

echo "<center>Successfully store in DATABASE</center>";

 

}

?>

<form name="add" method="post" action="add.php">

  <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0">

    <tr>

      <td colspan="4" style="background:#0066FF; color:#FFFFFF; font-size:20px">ADD STUDENT RECORD</td>

    </tr>

    <tr>

    <tr>

      <td>Enter Roll Number</td>

      <td><input type="text" name="roll" size="20"></td>

      <td>Enter Class</td>

      <td><input type="text" name="class" size="20"></td>

    </tr>

    <tr>

      <td>Enter Name of Student</td>

      <td><input type="text" name="name" size="20"></td>

      <td>Enter Father's Name</td>

      <td><input type="text" name="fname" size="20"></td>

    </tr>

    <tr>

      <td>Sex</td>

      <td><input type="radio" name="sex" value="Male">

        Male

        <input type="radio" name="sex" value="Female">

        Female </td>

      <td>Address1</td>

      <td><input type="text" name="addr1" size="20"></td>

    </tr>

    <tr>

      <td>Address2</td>

      <td><input type="text" name="addr2" size="20"></td>

      <td>Address3</td>

      <td><input type="text" name="addr3" size="20"></td>

    </tr>

    <tr>

      <td>City</td>

      <td><input type="text" name="city" size="20"></td>

      <td>Phone</td>

      <td><input type="text" name="phone" size="20"></td>

    </tr>

    <tr>

      <td>Email</td>

      <td><input type="text" name="email" size="20"></td>

      <td>Remarks</td>

      <td><input type="text" name="remarks" size="20"></td>

    </tr>

    <tr>

      <td colspan="4" align="center"><input type="hidden" name="do" value="store">

        <input type="submit" value="ADD RECORD"></td>

    </tr>

  </table>

</form>

<p align="center"><a href="index.php">Go Back to Home</a></p>

<?

include("search.php");?>

</body>

</html>

 

 

Edit.php

 

 

<?

mysql_connect("localhost");

mysql_select_db("test") or die("database could not connect ");

?>

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Update  Student  Record</title>

</head>

<body>

<?

if($_POST["do"]=="update")

{

$roll=$_POST["roll"];

$class=$_POST["class"];

$name=$_POST["name"];

$fname=$_POST["fname"];

$sex=$_POST["sex"];

$addr1=$_POST["addr1"];

$addr2=$_POST["addr2"];

$addr3=$_POST["addr3"];

$city=$_POST["city"];

$phone=$_POST["phone"];

$email=$_POST["email"];

$remarks=$_POST["remarks"];

$query="update student set name='$name',f_name='$fname',sex='$sex',addr1='$addr1',addr2='$addr2',addr3='$addr3',city='$city',phone='$phone',email='$email',remarks='$remarks' where roll=$roll";

mysql_query($query);

 

echo "<center>Successfully Updated in DATABASE</center>";

include("search.php");

 

}

?>

<center>

  <h1><u>Student Database</u></h1>

</center>

<?

$roll=$_GET["roll"];

$query="select * from student where roll='$roll'";

$result=mysql_query($query);

while ($row = mysql_fetch_array($result)) {

 

?>

<form name="update" method="post" action="edit.php">

  <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0">

    <tr>

      <td colspan="4" style="background:#0066FF; color:#FFFFFF; font-size:20px">ADD STUDENT RECORD</td>

    </tr>

    <tr>

    <tr>

      <td>Enter Roll Number</td>

      <td><? echo $row[0];?>

        <input type="hidden" name="roll" size="20" value="<? echo $row[0];?>"></td>

      <td>Enter Class</td>

      <td><input type="text" name="class" size="20" value="<? echo $row[1];?>" disabled="disabled"></td>

    </tr>

    <tr>

      <td>Enter Name of Student</td>

      <td><input type="text" name="name" size="20" value="<? echo $row[2];?>"></td>

      <td>Enter Father's Name</td>

      <td><input type="text" name="fname" size="20" value="<? echo $row[3];?>"></td>

    </tr>

    <tr>

      <td>Sex</td>

      <td><input type="radio" name="sex" value="Male" checked="checked">

        Male

        <input type="radio" name="sex" value="Female">

        Female </td>

      <td>Address1</td>

      <td><input type="text" name="addr1" size="20" value="<? echo $row[5];?>"></td>

    </tr>

    <tr>

      <td>Address2</td>

      <td><input type="text" name="addr2" size="20" value="<? echo $row[6];?>"></td>

      <td>Address3</td>

      <td><input type="text" name="addr3" size="20" value="<? echo $row[7];?>"></td>

    </tr>

    <tr>

      <td>City</td>

      <td><input type="text" name="city" size="20" value="<? echo $row[8];?>"></td>

      <td>Phone</td>

      <td><input type="text" name="phone" size="20" value="<? echo $row[9];?>"></td>

    </tr>

    <tr>

      <td>Email</td>

      <td><input type="text" name="email" size="20" value="<? echo $row[10];?>"></td>

      <td>Remarks</td>

      <td><input type="text" name="remarks" size="20" value="<? echo $row[11];?>"></td>

    </tr>

    <tr>

      <td colspan="4" align="center"><input type="hidden" name="do" value="update">

        <input type="submit" value="UPDATE RECORD"></td>

    </tr>

  </table>

</form>

<? } ?>

<p align="center"><a href="index.php">Go Back to Home</a></p>

</body>

</html>

 

 

 

Del.php

 

<?

mysql_connect("localhost");

mysql_select_db("test") or die("database could not connect ");

?>

<html>

<head>

<meta name="description" content="Php Code for View, Search, Edit and Delete Record" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Add Student  Record</title>

</head>

<body>

<?

$roll=$_GET["roll"];

$query="delete from student where roll=$roll";

mysql_query($query);

echo "<center>Successfully Deleted</center>";

include("search.php");

?>

</body>

</html>

 

 

 

 

If you found any error or if you have any feedback regarding this code example mail me at gunjankumarverma@gmail.com

 

if you have any information regarding Job, Study Material or any other information related to career. you can Post your article on our website. Click here to Register & Share your contents.
For Advertisment or any query email us at educratsweb@gmail.com

RELATED POST

1. Mobile Data Protection Market Plays An Essential Role In Technology and Media Industry 2021
Mobile Data Protection Market Plays An Essential Role In Technology and Media Industry 2021Competitive Analysis For Mobile Data Protection Market is one of the most comprehensive and latest additions to TechMarketReports (Market.us) Reports Database. The Mobile Data Protection market rep
2. IIT develops portable tech-traditional eco-friendly mobile cremation system
Indian Institute of Technology, Ropar has developed a prototype of a moveable electric cremation system which claims to be using first of its kind technology that involves smokeless cremation despite using wood. It uses half of the wood otherwise required for the cremation and still is eco-friendly because of the technology that uses combustion air system.   It is based on wick-stove technology in which the wick when lighted glows yellow. This is converted into smokeless blue fla
3. DRDO develops Critical Near Isothermal Forging Technology for aeroengines
Defence Research and Development Organisation (DRDO) has established the near isothermal forging technology to produce all the five stages of high-pressure compressors (HPC) discs out of difficult-to-deform titanium alloy using its unique 2000 MT isothermal forge press. The technology has been developed by Defence Metallurgical Research Laboratory (DMRL), a premier metallurgical laboratory of DRDO at Hyderabad. This is a crucial technology for establishing self-reliance in aeroengine technology.  Wi
4. Php Code for View, Search, Edit and Delete Record from MySql Table
PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. This is the simple Code Example through which you can insert, Delete, View , Update from MySql Database.   Paste this code and save the file as written above. Create a database named te
5. Prime Minister pays tributes to scientists on the National Technology Day
Prime Minister Shri Narendra Modi today paid tributes to all the scientists in the country who are using science and technology to bring a positive difference in the lives of others. Shri Modi was tweeting on the occasion of National Technology Day. “On National Technology Day, our nation salutes all those who are leveraging technology to bring a positive difference in the lives of others. We remember the exceptional achievement of our scientists on this day in 1998. It was a la
6. CSIR-Central Scientific Instruments Organisation (CSIO) transfers the UV Disinfection technology to combat SARS-CoV-2 to 27 indigenous manufacturers
There has been increasing evidence for airborne route of transmission of SARS-CoV-2 via aerosols which is now considered to be important by international agencies WHO, REHVA, ASHRAE and by health authorities in several countries. The airborne transmission is a major risk in indoor settings. Significantly, research carried out by CSIR constituent labs, Centre for Cellular and Molecular Biology (CSIR-CCMB) and CSIR-Institute of Microbial Technology (CSIR-IMTECH) in September 2020 had demonstrated experimen
7. Recycling Carbon technology by Bangalore startup receives TDB National Award 2021
A Bangalore based startup has received the National Award 2021 from Technology Development Board (TDB) for developing a commercial solution for conversion of CO2 to chemicals and fuels. Breathe Applied Sciences, a startup incubated at Jawaharlal Nehru Centre for Advanced Scientific Research (JNCASR) developed efficient catalysts and methodologies for the conversion of CO2 to methanol and other chemicals. It has led to improvisation of process engineering to enhance the production of c
8. CSIR-CMERI comes up with High Flow Rate Water Purification Technology for Fluoride and Iron Removal
NEED OF THE TECHNOLOGY: The contamination of fluoride and iron in drinking water is increasing day by day. Iron is the most abundant trace element in human body, responsible for accomplishment of vital biological functions such as gastrointestinal processes and the regulation of body temperature. But when iron level in water is beyond 0.3 ppm (as per WHO guideline), it shows several adverse effects including liver disease, irregular heart rhythm and neuronal disorder etc.
9. Rajya Sabha passes Indian Institutes of Information Technology Laws (Amendment) Bill, 2020 today
Rajya Sabha passed Indian Institutes of Information Technology Laws (Amendment) Bill, 2020 in New Delhi today. The Indian Institutes of Information Technology Act of 2014 and Indian Institutes of Information Technology (Public-Private Partnership) Act, 2017 are the unique initiatives of the Government of India to impart knowledge in the field of Information Technology to provide solutions to the challenges faced by the country.The Indian Institutes of Information Technology Laws (Amendment) Bill, 2020 wa
10. Science, Technology and Innovation Policy, 2020
Science, Technology and Innovation Policy, 2020 Science, Technology and Innovation Policy, 2020 Introduction As India and the world reorient in the wake of the COVID-19 crisis, a landmark policy initiative has been flagged by the Government of India. The Science, Technology and Innovation Poli
11. What is Blockchain; AKA the Bitcoin technology?
What is Blockchain; AKA the Bitcoin technology?Blockchain is an online mechanism that offers guarantees against attacks and fraud in business and administrative processes. It’s a collaborative principle. The Blockchain was born from the conception of Bitcoin but it has already transcended the field of cryptocurrency. The emerg
12. Government notifies Information Technology (IntermediaryGuidelines and Digital Media Ethics Code) Rules 2021
Amidst growing concerns around lack of transparency, accountability and rights of users related to digital media and after elaborate consultation with the public and stakeholders, the Information Technology (Intermediary Guidelines and Digital Media Ethics Code) Rules 2021 has been framed in exercise of powers under section 87 (2) of the Information Technology Act, 2000 and in supersession of the earlier Information Technology (Intermediary Guidelines) Rules 2011. While finalizing these Rules,
13. Agricultural Technology Information Centre (ATIC)
Agricultural Technology Information Centre (ATIC) started functioning from 2001 in Umiam, Meghalaya in the premises of ICAR Research Complex for NEH Region. This is a single window system to allow optimistic interaction between farmers and scientists for effective technology transfer and livelihood improvement. The outstations regional centers and Krishi Vigyan Kendras situated in different districts are also involved and part of the system for meeting the requirements of the farmers in various areas of
14. Agricultural Technology Information Centre (ATIC)
Agricultural Technology Information Centre (ATIC) started functioning from 2001 in Umiam, Meghalaya in the premises of ICAR Research Complex for NEH Region. This is a single window system to allow optimistic interaction between farmers and scientists for effective technology transfer and livelihood improvement. The outstations regional centers and Krishi Vigyan Kendras situated in different districts are also involved and part of the system for meeting the requirements of the farmers in various areas of
15. Agricultural Technology Information Centre (ATIC)
Agricultural Technology Information Centre (ATIC) started functioning from 2001 in Umiam, Meghalaya in the premises of ICAR Research Complex for NEH Region. This is a single window system to allow optimistic interaction between farmers and scientists for effective technology transfer and livelihood improvement. The outstations regional centers and Krishi Vigyan Kendras situated in different districts are also involved and part of the system for meeting the requirements of the farmers in various areas of
16. National Technology Day to be celebrated focusing on rebooting the economy through S&T
National Technology Day to be celebrated focusing on rebooting the economy through S&T The conference will bring together Scientists, Technocrats, Government officials, Diplomats, WHO officials and dignitaries from national and international Industry, Research Institutions and Academic Institutions   A high-level digital conference on ‘Rebooting the Economy through Science, Technology and Research Translations titled RESTART’ will be o
17. Department of Science & Technology is having three binational Centres
Presently the Department of Science & Technology, Govt. of India is having three binationalCentres namely Indo-French Centre for Promotional of Advanced Research (IFCPAR)established with France in 1987, Indo-US Science & Technology Forum (IUSSTF) established in2000 with USA and Indo-German Science & Technology Centre (IGSTC) established in 2010under inter-governmental agreements. During last three years, the following new programmes have been launched by these binationalCentres:
18. Government is implementing several schemes to encourage students/youth of the country towards the field of science and technology: Dr. Harsh Vardhan
It has been a part of Government’s Science and Technology (S&T) policy toencourage the students/youth of the country towards the field of science and technology. The first three key elements of Science, Technology, and Innovation (STI) Policy of 2013 Are: Promoting the spread of scientific temper amongst all sections of society. Enhancing skill for applications of science among the young from all social strata. Making careers in scienc
19. India International Science Festival-2020 will showcase 41 events highlighting multi-dimensional aspects of science, technology and innovation in India
Several curtain raiser events are being organized for generating awareness about the 6thIndia International Science Festival (IISF-2020) to be held virtually this year. At such an event at CSIR – Indian Institute of Toxicology Research, Lucknow,  Dr Shekhar C Mande, Secretary, Department of Scientific and Industrial Research (DSIR), Director General, Council of Scientific and Industrial Research and Chairman, Steering Committee, IISF – 2020, in his key note address, said that t
20. Zircon Tech is promoting the use of blockchain technology for electronic shipping invoices
Zircon Tech is promoting the use of blockchain technology for electronic shipping invoicesGlobal Share is a business whose mission is to improve business processes. This company has been working along with Zircon Tech. Its common project is the development of a solution for the effective handling of the info
21. 321 Free Tools for Teachers - Free Educational Technology
Jacob Lund/Shutterstock.com Free Educational Technology for Teachers Do you support Free Technology for Teachers? If Yes, I highly encourage you to share this Free Educational Technology Reso
We would love to hear your thoughts, concerns or problems with anything so we can improve our website educratsweb.com ! email us at educratsweb@gmail.com and submit your valuable feedback.
Save this page as PDF | Recommend to your Friends

Subscribe to our Telegram channel https://t.me/educratswebchannel | PHP CODE FOR VIEW, SEARCH, EDIT AND DELETE RECORD FROM MYSQL TABLE #EDUCRATSWEB educratsweb.com Technology 2018-09-19
PHP CODE FOR VIEW, SEARCH, EDIT AND DELETE RECORD FROM MYSQL TABLE | Google Cached Pages

https://bhojpuri-actor-actress.blogspot.com/ | https://sarkariniyukti.blogspot.com/ | https://educratsweb.blogspot.com/ | https://bhaktisangam.blogspot.com/ | https://bharatpagesblog.blogspot.com/ | https://bcspatna.blogspot.com/ | https://bizinfozones.blogspot.com/ | https://cityzoneeducation.blogspot.com/ | https://consptech.blogspot.com/ | https://saralmaterials.blogspot.com/ | https://ekbihar.blogspot.com/ | https://indiahealthplus.blogspot.com/ | https://gktalk.blogspot.com/ | https://gunjanphoto.blogspot.com/ | https://mahuli-patna.blogspot.com/ | https://modicareblog.blogspot.com/ | https://biharnalanda.blogspot.com/ | https://parsapatna.blogspot.com/ | https://prakashparv.blogspot.com/ | https://chitraguptajimaharaj.blogspot.com/ | https://shrishirdisaibabasansthan.blogspot.com/ | https://speakdoor.blogspot.com/ | https://supremedealin.blogspot.com/ | https://supremedealblog.blogspot.com/