File tree Expand file tree Collapse file tree 7 files changed +86
-0
lines changed Expand file tree Collapse file tree 7 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ <<<<<<< HEAD
1
2
the added text master
3
+ =======
4
+ this is added text using ab account
5
+ >>>>>>> 4fec8af02c9ff5d9fefb5c4f23c69b29d796e539
Original file line number Diff line number Diff line change
1
+ <<<<<<< HEAD
1
2
// index.php
2
3
// load and initialize any global libraries
3
4
17
18
header('HTTP/1.1 404 Not Found');
18
19
echo '<html><body><h1>Page Not Found</h1></body></html>';
19
20
}
21
+ =======
22
+ <?php
23
+ // index.php
24
+ $ link = new PDO ("mysql:host=localhost;dbname=blog_db " , 'myuser ' , 'mypassword ' );
25
+ $ result = $ link ->query ('SELECT id, title FROM post ' );
26
+ ?>
27
+ <!DOCTYPE html>
28
+ <html>
29
+ <head>
30
+ <title>List of Posts</title>
31
+ </head>
32
+ <body>
33
+ <h1>List of Posts</h1>
34
+ <ul>
35
+ <?php while ($ row = $ result ->fetch (PDO ::FETCH_ASSOC )): ?>
36
+ <li>
37
+ <a href="/show.php?id=<?= $ row ['id ' ] ?> ">
38
+ <?= $ row ['title ' ] ?>
39
+ </a>
40
+ </li>
41
+ <?php endwhile ?>
42
+ </ul>
43
+ </body>
44
+ </html>
45
+ <?php
46
+ $ link = null ;
47
+ ?>
48
+ >>>>>>> 4fec8af02c9ff5d9fefb5c4f23c69b29d796e539
Original file line number Diff line number Diff line change
1
+ <<<<<<< HEAD
1
2
/ model .php
2
3
function open_database_connection ()
3
4
{
@@ -20,4 +21,17 @@ function get_all_posts()
20
21
}
21
22
close_database_connection ($link );
22
23
return $posts ;
24
+ =======
25
+ // model.php
26
+ function get_post_by_id ($id )
27
+ {
28
+ $link = open_database_connection ();
29
+ $query = 'SELECT created_at , title , body FROM post WHERE id =:id ';
30
+ $statement = $link ->prepare ($query );
31
+ $statement ->bindValue (' :id' , $id , PDO :: PARAM_INT );
32
+ $statement ->execute ();
33
+ $row = $statement ->fetch (PDO :: FETCH_ASSOC );
34
+ close_database_connection ($link );
35
+ return $row ;
36
+ >>>>>>> 4fec8af02c9ff5d9fefb5c4f23c69b29d796e539
23
37
}
Original file line number Diff line number Diff line change
1
+ <!-- templates/layout.php -->
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title><?= $ title ?> </title>
6
+ </head>
7
+ <body>
8
+ <?= $ content ?>
9
+ </body>
10
+ </html>
Original file line number Diff line number Diff line change
1
+ <<<<<<< HEAD
1
2
!-- templates/list.php -->
2
3
<!DOCTYPE html>
3
4
<html>
18
19
</ul>
19
20
</body>
20
21
</html>
22
+ =======
23
+ <!-- templates/list.php -->
24
+ <?php $ title = 'List of Posts ' ?>
25
+ <?php ob_start () ?>
26
+ <h1>List of Posts</h1>
27
+ <ul>
28
+ <?php foreach ($ posts as $ post ): ?>
29
+ <li>
30
+ <a href="/show.php?id=<?= $ post ['id ' ] ?> ">
31
+ <?= $ post ['title ' ] ?>
32
+ </a>
33
+ </li>
34
+ <?php endforeach ?>
35
+ </ul>
36
+ <?php $ content = ob_get_clean () ?>
37
+ <?php include 'layout.php ' ?>
38
+ >>>>>>> 4fec8af02c9ff5d9fefb5c4f23c69b29d796e539
Original file line number Diff line number Diff line change
1
+ <!-- templates/show.php -->
2
+ <?php $ title = $ post ['title ' ] ?>
3
+
4
+ <?php ob_start () ?>
5
+ <h1><?= $ post ['title ' ] ?> </h1>
6
+ <div class="date"><?= $ post ['created_at ' ] ?> </div>
7
+ <div class="body">
8
+ <?= $ post ['body ' ] ?>
9
+ </div>
10
+ <?php $ content = ob_get_clean () ?>
11
+ <?php include 'layout.php ' ?>
You can’t perform that action at this time.
0 commit comments