FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpwpg/sqlite.php at master · inec/phpwpg · GitHub
inec
/
phpwpg
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
phpwpg
/
sqlite.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (31 loc) · 1.06 KB
Breadcrumbs
phpwpg
/
sqlite.php
Copy path
File metadata and controls
35 lines (31 loc) · 1.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
try
{
//open the database
$
db
=
new
PDO
(
'
sqlite:dogsDb_PDO.sqlite
'
);
//create the database
$
db
->
exec
(
"
CREATE TABLE Dogs (Id INTEGER PRIMARY KEY, Breed TEXT, Name TEXT, Age INTEGER)
"
);
//insert some data...
$
db
->
exec
(
"
INSERT INTO Dogs (Breed, Name, Age) VALUES ('Labrador', 'Tank', 2);
"
.
"
INSERT INTO Dogs (Breed, Name, Age) VALUES ('Husky', 'Glacier', 7);
"
.
"
INSERT INTO Dogs (Breed, Name, Age) VALUES ('Golden-Doodle', 'Ellie', 4);
"
);
//now output the data to a simple html table...
print
"
<table border=1>
"
;
print
"
<tr><td>Id</td><td>Breed</td><td>Name</td><td>Age</td></tr>
"
;
$
result
=
$
db
->
query
(
'
SELECT * FROM Dogs
'
);
foreach
(
$
result
as
$
row
)
{
print
"
<tr><td>
"
.
$
row
[
'
Id
'
].
"
</td>
"
;
print
"
<td>
"
.
$
row
[
'
Breed
'
].
"
</td>
"
;
print
"
<td>
"
.
$
row
[
'
Name
'
].
"
</td>
"
;
print
"
<td>
"
.
$
row
[
'
Age
'
].
"
</td></tr>
"
;
}
print
"
</table>
"
;
// close the database connection
$
db
=
NULL
;
}
catch
(
PDOException
$
e
)
{
print
'
Exception :
'
.
$
e
->
getMessage
();
}
?>
Back
|
FazBrowse Home
|
New Git URL