P. 1
Php Code Example for View Edit Delete Search Update Database Table From Gunjan Kumar

Php Code Example for View Edit Delete Search Update Database Table From Gunjan Kumar

Views: 209|Likes:

More info:

Published by: Anushyendan Selvanayagam on Oct 17, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/04/2014

pdf

text

original

Php Code for View, Search, Edit and Delete Record

2010

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 generalpurpose 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. 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; fontsize: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>

Code Example

Page 1

Edit and Delete Record" /> <meta http-equiv="Content-Type" content="text/html. while ($row = mysql_fetch_array($result)) { Code Example Page 2 . ?> <html> <head> <meta name="description" content="Php Code for View. $result=mysql_query($query).php"> <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0"> <tr> <td colspan="3" style="background:#0066FF. Search.php (Snapshot) Student Database Search Enter Search Keyword Search Add Record Search.</td> <? $search=$_POST["search"]. color:#FFFFFF. Edit and Delete Record 2010 Index.php <? mysql_connect("localhost").Php Code for View. fontsize: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. 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. Search. $query="select * from student where name like '%$search%' ". $flag=0. mysql_select_db("test") or die("database could not connect ").

Php Code for View. 10 3.$row[0].php">Add Record</a></th> </tr> </table> </form> </body> </html> Search.php?roll=". Edit and Delete Record 2010 $flag=1. ?> <tr> <td colspan="3">&nbsp. Radhe Shyam Nikki Kumari.php(Snapshots) Student Database Search Enter Search Keyword Roll & class 1. mysql_select_db("test") or die("database could not connect ").</td></tr> <tr bgcolor="#CCCCCC"> <th colspan="3" align="right"><a href="add.$row[1].$row[2]."'>Delete</a></td></tr>". 10 Name & Father's Name Gunjan Kumar. 10 4. ?> <html> <head> <meta name="description" content="Php Code for View. charset=iso-8859-1" /> <title>View Student Record</title> </head> <body> <center><h1><u>Student Database</u></h1></center> Code Example Page 3 .php?roll=".$row[3].$row[0]. } if($flag==0) echo "<tr><td colspan='3' align='center' style='color:red'>Record not found</td></tr>".".".$row[0].php?roll=". ". ". echo "<tr ><td>". Search."</a></td><td><a href='edit. Prem Shankar Sonali Verma. Manohar pd Edit | Delete Edit | Delete Edit | Delete Search Add Record View."</td><td><a href='view."'>". Search.php <? mysql_connect("localhost").$row[0]."'>Edit</a> | <a href='del. Edit and Delete Record" /> <meta http-equiv="Content-Type" content="text/html.

$query="select * from student where roll='$roll'".?></td></tr> <tr> <td>Email</td><td><? echo $row[10]. Search.?></td> <td>Remarks</td><td><? echo $row[11].?></td> <td> Class</td><td><? echo $row[1].?></td></tr> <tr> <td>Address2</td><td><? echo $row[6].php">Go Back to Home</a></p> </body> </html> Code Example Page 4 .?></td> </tr> <tr> <td>Sex</td><td><? echo $row[4].?></td> <td>Address3</td><td><? echo $row[7].?></td> <td>Phone</td><td><? echo $row[9]. font-size:20px">VIEW STUDENT DATABASE</td></tr> <tr> <td> Roll Number</td><td><? echo $row[0].?></td></tr> <tr> </table> <? } ?> <p align="center"><a href="index. 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.?></td></tr> <tr> <td>City</td><td><? echo $row[8].Php Code for View. Edit and Delete Record 2010 <? $roll=$_GET["roll"]. color:#FFFFFF.?></td> </tr> <tr> <td> Name of Student</td><td><? echo $row[2].?></td> <td>Address1</td><td><? echo $row[5]. $result=mysql_query($query).?></td> <td> Father's Name</td><td><? echo $row[3].

Edit and Delete Record" /> <meta http-equiv="Content-Type" content="text/html.com Remarks Go Back to Home Add. Edit and Delete Record 2010 View. Search. mysql_select_db("test") or die("database could not connect "). Search. $fname=$_POST["fname"].Php Code for View.php <? mysql_connect("localhost"). Code Example Page 5 .php(Snapshots) Student Database VIEW STUDENT DATABASE Roll Number 1 Class 10 Name of Student Gunjan Kumar Sex Address2 City Email Male Lohia Nagar Patna Father's Name Prem Shankar Address1 Address3 Phone 9334457195 No remarks Kankarbagh gunjankumarverma@gmail. $class=$_POST["class"]. 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"]. ?> <html> <head> <meta name="description" content="Php Code for View. $name=$_POST["name"].

} ?> <form name="add" method="post" action="add. echo "<center>Successfully store in DATABASE</center>". mysql_query($query).Php Code for View. $email=$_POST["email"]. Edit and Delete Record 2010 $sex=$_POST["sex"]. $addr1=$_POST["addr1"]. color:#FFFFFF. Search. $addr2=$_POST["addr2"].'$fname'. $phone=$_POST["phone"]. $query="insert into student value($roll.'$remarks')".'$phone'. $remarks=$_POST["remarks"].'$addr3'. $addr3=$_POST["addr3"]. fontsize: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> Code Example Page 6 .'$addr1'.'$class'. $city=$_POST["city"].'$city'.'$ email'.'$sex'.php"> <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0"> <tr> <td colspan="4" style="background:#0066FF.'$addr2'.'$name'.

?> </body> </html> Add. Search.php(Snapshots) Student Database ADD STUDENT RECORD Enter Roll Number Enter Name of Student Sex Address2 City Email ADD RECORD Enter Class Enter Father's Name Male Female Address1 Address3 Phone Remarks Go Back to Home Edit. Search. mysql_select_db("test") or die("database could not connect ").php <? mysql_connect("localhost").php").Php Code for View. Edit and Delete Record" /> Code Example Page 7 . Edit and Delete Record 2010 <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. ?> <html> <head> <meta name="description" content="Php Code for View.php">Go Back to Home</a></p> <? include("search.

php"> <table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px" align="center" border="0"> <tr> <td colspan="4" style="background:#0066FF. include("search. $addr2=$_POST["addr2"].php").phone='$phone'. mysql_query($query).remarks='$remarks' where roll=$roll". $city=$_POST["city"]. $email=$_POST["email"]. $query="update student set name='$name'. color:#FFFFFF. charset=iso-8859-1" /> <title>Update Student Record</title> </head> <body> <? if($_POST["do"]=="update") { $roll=$_POST["roll"].sex='$sex'. $sex=$_POST["sex"]. Edit and Delete Record 2010 <meta http-equiv="Content-Type" content="text/html.addr2='$addr2'. $class=$_POST["class"]. $phone=$_POST["phone"]. fontsize:20px">ADD STUDENT RECORD</td> </tr> <tr> <tr> <td>Enter Roll Number</td> <td><? echo $row[0].city='$city'.addr3='$ad dr3'.?>"></td> <td>Enter Class</td> Code Example Page 8 . $query="select * from student where roll='$roll'". $addr1=$_POST["addr1"]. $remarks=$_POST["remarks"]. $name=$_POST["name"]. Search.addr1='$addr1'. while ($row = mysql_fetch_array($result)) { ?> <form name="update" method="post" action="edit.Php Code for View. } ?> <center> <h1><u>Student Database</u></h1> </center> <? $roll=$_GET["roll"].email='$email'. echo "<center>Successfully Updated in DATABASE</center>". $result=mysql_query($query).?> <input type="hidden" name="roll" size="20" value="<? echo $row[0]. $addr3=$_POST["addr3"]. $fname=$_POST["fname"].f_name='$fname'.

Edit and Delete Record 2010 <td><input type="text" name="class" size="20" value="<? echo $row[1].?>"></td> </tr> <tr> <td>City</td> <td><input type="text" name="city" size="20" value="<? echo $row[8].?>"></td> </tr> <tr> <td>Address2</td> <td><input type="text" name="addr2" size="20" value="<? echo $row[6].php">Go Back to Home</a></p> </body> </html> Code Example Page 9 .?>"></td> <td>Address3</td> <td><input type="text" name="addr3" size="20" value="<? echo $row[7].?>"></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" size="20" value="<? echo $row[10]. Search.?>"></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.?>"></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].?>" disabled="disabled"></td> </tr> <tr> <td>Enter Name of Student</td> <td><input type="text" name="name" size="20" value="<? echo $row[2].Php Code for View.?>"></td> <td>Remarks</td> <td><input type="text" name="remarks" size="20" value="<? echo $row[11].?>"></td> <td>Phone</td> <td><input type="text" name="phone" size="20" value="<? echo $row[9].?>"></td> <td>Enter Father's Name</td> <td><input type="text" name="fname" size="20" value="<? echo $row[3].

$query="delete from student where roll=$roll". Search. echo "<center>Successfully Deleted</center>". Edit and Delete Record 2010 Edit. Edit and Delete Record" /> <meta http-equiv="Content-Type" content="text/html.Php Code for View.chand 3 Sonali Verm Enter Class Enter Father's Name Female Address1 Address3 Phone Remarks 10 Radhe Shya Male Go Back to Home Del.php <? mysql_connect("localhost"). include("search. ?> <html> <head> <meta name="description" content="Php Code for View. ?> Code Example Page 10 . mysql_select_db("test") or die("database could not connect ").php(Snapshots) Student Database ADD STUDENT RECORD Enter Roll Number Enter Name of Student Sex Address2 City Email UPDATE RECORD Patna sonali. charset=iso-8859-1" /> <title>Add Student Record</title> </head> <body> <? $roll=$_GET["roll"]. Search.php"). mysql_query($query).

Php Code for View. Search.infozones.com Code Example Page 11 . Edit and Delete Record 2010 </body> </html> You can also find this code from http://infozones. Online GS Quiz and Online Reference Notes Know About Bihar from Bihar Directory Visit http://bihar.rar Change the code as per your requirement Visit http://infozones.in/docs/ex1.in for Job(India) .in If you found any error or if you have any feedback regarding this code example mail me at gunjankumarverma@gmail.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->