-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdbcreate.php
126 lines (95 loc) · 2.57 KB
/
dbcreate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
$servername = "localhost";
$username ="root";
$password="";
$dbname = "summer24";
// MySQLi OO Way
$con = new mysqli($servername, $username,$password,$dbname);
if ($con->connect_error)
die("<br> Connection ". $con->connect_error);
else
echo "<br><h2>Alhamdulillah DB Server Is Connected </h2>";
// $sql = "CREATE database seu_cse";
/*
$sql2 ="CREATE table seucse (
id int not null auto_increment,
names varchar(20),
sage int,
addr varchar (100),
bg varchar(3),
primary key (id)
)";
$res = $con->query($sql2);
if ($res == TRUE)
echo "<br>New Table Created";
else
echo "<br> Database Not Created";
*/
/*
$name = "Debosree"; //POST
$age = 19; // POST
$add = "Chittagong"; // POST
$bg = "A+"; // POST
$SQLin = "INSERT INTO seucse (names,sage,addr,bg) VALUES ('".$name."',".$age.",'".$add."','".$bg."')";
$res=$con->query($SQLin);
if ($res == TRUE)
echo "<br>New record added successfully<br>";
else
echo "<br> Error: ". $SQLin. "<br>". $con->error;
*/
// Read the Data
$SQLse = "SELECT * FROM seucse";
$res=$con->query($SQLse);
//var_dump($res);
//$asores = mysqli_fetch_assoc($res);
//print_r($asores);
// LOOP
$i=1;
?>
<?php
echo "<table border='1'>";
echo "<thead> <tr><th>SL</th><th>NAME</th><th>Age</th><th>Address</th><th>BloodGroup</th></tr></thead";
while ($row = $res->fetch_assoc())
{
//echo "<br>";
//echo $row['names'];
//echo $i.">>". $row['names']."++++".$row['sage']."++++".$row['addr']."++++".$row['bg'];
echo "<tr>";
echo "<td>".$i."</td><td>".$row['names']."</td><td>".$row['sage']."</td><td>".$row['addr']."<td>".$row['bg']."</td>";
echo "</tr>";
$i++;
}
?>
</table>
<?php
//var_dump($res);
//echo "<pre>";
$con->close();
// MySQLi Pro way
// $pcon = mysqli_connect($servername,$username,$password,$dbname);
// if (!$pcon)
// die("<br> Connection Failed ". mysqli_connect_error());
// else
// echo "<br> <h2> PRW Alhamdulillah DB Connected";
// $SQLse = "SELECT * FROM seucse";
// $pres=mysqli_query($pcon,$SQLse);
// print_r($pres);
// $res= mysqli_query($pcon,$sql);
// if ($res == TRUE)
// echo "<br>New Database Created";
// else
// echo "<br> Database Not Created";
// PDO
// try
// {
// $pdocon = new PDO("mysql:host=$servername; dbname=$dbname",$username,$password);
// $pdocon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// echo "<br> PDO CONNECTED";
// }
// catch(PDOException $e)
// {
// echo "<br> PDO Connection ERROR ".$e->getMessage();
// }
// $psql = "CREATE DATABASE pdobd";
// $pdocon->query($psql);
?>