File tree 8 files changed +168
-0
lines changed
8 files changed +168
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ $ servername ="localhost " ;
3
+ $ username ="root " ;
4
+ $ password ="" ;
5
+ //connection to mysql
6
+ $ conn =mysqli_connect ($ servername ,$ username ,$ password );
7
+ if (!$ conn )
8
+ {
9
+ die ("Connection Failed " .mysql_error ());
10
+ }
11
+
12
+ //Create database
13
+ $ sql ="CREATE DATABASE lname " ;//change name to change database
14
+
15
+ if ( mysqli_query ($ conn ,$ sql ) )
16
+ {
17
+ echo ("Database create successfully " );
18
+ }
19
+ else
20
+ {
21
+ echo ("Error Creating Database " .mysqli_error ());
22
+ }
23
+ mysqli_close ($ conn );
24
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ $ servername ="localhost " ;
3
+ $ username ="root " ;
4
+ $ password ="" ;
5
+
6
+ $ conn =mysql_connect ($ servername ,$ username ,$ password );
7
+ if (!$ conn )
8
+ {
9
+ die ("Connection Failed " .mysql_error ());
10
+ }
11
+ else
12
+ echo "Connection Successful<br> " ;
13
+ //selecting database
14
+ $ dbcheck =mysql_select_db ("lname " );
15
+
16
+ if (!$ dbcheck )
17
+ {
18
+ echo "Error selecting DB " .mysql_error ();
19
+ }
20
+ else echo "Database Selected<br> " ;
21
+
22
+ //Creating table
23
+ $ sql ="Create table student (sid int primary key, sname varchar(20)) " ;
24
+
25
+ $ check =mysql_query ($ sql ,$ conn );
26
+ if (!$ check )
27
+ echo "Error creating Table " .mysql_error ();
28
+ else echo "Table created successfully " ;
29
+
30
+ mysql_close ($ conn );
31
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ include 'db.php ' ;
3
+
4
+ //create table
5
+ //$sql="Create table emp (eid int primary key, ename varchar(20))";
6
+ //$check=mysql_query($sql,$conn);
7
+ //if(!$check)
8
+ //echo "Error creating table".mysql_error();
9
+
10
+ //INSERTING DATA IN TABLE
11
+ $ sql ="Insert into emp values(1,'shaurya') " ;
12
+ mysql_query ($ sql ,$ conn );
13
+ $ sql ="Insert into emp values(2,'saranch') " ;
14
+ mysql_query ($ sql ,$ conn );
15
+ $ sql ="Insert into emp values(3,'aurya') " ;
16
+ mysql_query ($ sql ,$ conn );
17
+
18
+
19
+ mysql_close ($ conn );
20
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ include 'db.php ' ;
3
+
4
+ $ id =$ _GET ['eid ' ];
5
+ $ name =$ _GET ['ename ' ];
6
+
7
+ $ sql ="INSERT INTO `emp` (`eid`,`ename`) values (' $ id',' $ name') " ;
8
+ $ check =mysql_query ($ sql ,$ conn );
9
+ if (!$ check )
10
+ die ( "Error inserting data " .mysql_error () );
11
+ else echo "Data Inserted Succesfully " ;
12
+
13
+ mysql_close ($ conn );
14
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ include 'db.php ' ;
3
+ $ sql = "select eid,ename from emp " ;
4
+ $ result = mysql_query ($ sql ,$ conn );
5
+
6
+ while ($ row =mysql_fetch_array ($ result ))
7
+ {
8
+ echo $ row ['eid ' ]." " .$ row ['ename ' ]."<br> " ;
9
+ }
10
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ $ servername ="localhost " ;
3
+ $ username ="root " ;
4
+ $ password ="" ;
5
+
6
+ $ conn =mysql_connect ($ servername ,$ username ,$ password );
7
+ if (!$ conn )
8
+ echo "Error in Connection " .mysql_error ();
9
+
10
+ $ dbcheck =mysql_select_db ("lname " );
11
+ if (!$ dbcheck )
12
+ echo "Error selecting Database<br> " .mysql_error ();
13
+ //else echo "Success";
14
+
15
+ //mysql_close($conn);
16
+
17
+ ?>
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < title >
5
+ SHAURYA</ title >
6
+ </ head >
7
+
8
+ < body style ="background-color:pink ">
9
+
10
+
11
+
12
+
13
+ < h1 style ="margin:auto;color:blue;text-align:center "> SHAURYA</ h1 >
14
+ < br > < br > < br > < br > < br > < br >
15
+
16
+
17
+ < form name ="Nameform " action ="database4.php " method ="get ">
18
+ <!-- <form action="myphp.php" method="get"> -->
19
+ Enter eid:< br >
20
+ < input type ="number " name ="eid "> < br >
21
+ First name:< br >
22
+ < input type ="text " name ="ename "> < br > < br >
23
+ < input type ="submit " value ="submit ">
24
+ </ form >
25
+
26
+ </ body >
27
+ </ html
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html >
3
+ <head >
4
+ <title >
5
+ SHAURYA </title >
6
+ </head >
7
+
8
+ <body style =" background-color :pink " >
9
+
10
+
11
+
12
+ <h1 style =" margin :auto ;color :blue ;text-align :center " > SHAURYA </h1 >
13
+ <br ><br ><br ><br ><br ><br >
14
+
15
+
16
+ <form name =" Nameform" >
17
+ <!-- <form action="myphp.php" method="get"> -->
18
+
19
+ First name :<br >
20
+ <input type =" text" name =" fname" ><br ><br >
21
+ <input type =" submit" value =" submit" >
22
+ </form >
23
+
24
+ </body >
25
+ </html >
You can’t perform that action at this time.
0 commit comments