-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewcontactsfromdatabase.php
76 lines (44 loc) · 1.68 KB
/
viewcontactsfromdatabase.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
<?php
// connent to MySQL server
include("connecttomysql.php");
// select "*" infor from the specified relation
$sql = "SELECT * FROM contactinfo";
$result = mysql_query($sql, $dbh)
or die("Something is wrong with your SQL statement.");
$outputString = '';
$formatString = 'First Name: %s <br /> Last Name: %s <br /> Address: %s <br /> State: %s <br />Zip: %s <br /> Telephone: %s <br /> Email: %s<br /><br /><br />';
$contactValues;
// create array of input
while ($row = mysql_fetch_array($result)) {
$contactValues= array();
$contactValues[] = $row['first_name'];
$contactValues[] = $row['last_name'];
$contactValues[] = $row['address'];
$contactValues[] = $row['state'];
$contactValues[] = $row['zip'];
$contactValues[] = $row['telephone'];
$contactValues[] = $row['email'];
$outputString .= sprintf($formatString, $contactValues[0], $contactValues[1], $contactValues[2], $contactValues[3], $contactValues[4], $contactValues[5], $contactValues[6]);
}
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact Form</title>
<meta http-equiv="content-script-type" content="text/javascript" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="page-container">
<h1>Existing Contacts</h1>
<?php
echo $outputString;
?>
<div class="form-actions">
<a href="contactform.php">Return to main page</a>
</div>
</div>
</body>
</html>