-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
63 lines (57 loc) · 1.48 KB
/
functions.php
File metadata and controls
63 lines (57 loc) · 1.48 KB
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
<?php
// require 'Records.php';
function connectToDb(){
return new PDO(
'mysql:host=127.0.0.1;dbname=records_info','root',''
);
}
function insert($pdo,$table,$data){
$sql="INSERT INTO $table SET " ;
foreach($data as $field=>$value){
$fieldSQL[]="$field='$value'";
}
$sql.=implode(',',$fieldSQL);
$statement=$pdo->prepare($sql);
$statement->execute();
}
?>
<style>
.table{
/* background-color: burlywood; */
background-color: bisque;
padding: 10px;
margin-left: 20%;
}
.r1{
background-color: navy;
color:goldenrod;
}
.r1:hover{
background-color: #7975AF;
}
</style>
<table border="1" class="table" cellspacing="2" cellpadding="10">
<tr class="r1">
<th>Name</th>
<th>Email</th>
<th>Gender</th>
<th>Phone</th>
<th>DOB</th>
</tr>
<?php
function selectAll(PDO $pdo,string $table,string $class){
$statement=$pdo->prepare('select * from '.$table);
$statement->execute();
$result= $statement->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $state){
echo '<tr>';
echo '<th>'.$state['name'].'</th>' ;
echo '<th>'.$state['email'].'</th>';
echo'<th>'.$state['gender'].' </th>';
echo '<th>'.$state['phone'].'</th>';
echo '<th>'.$state['date'].'</th>';
echo '</tr>';
// echo '<br>';
}
}
?>