Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L lab-exercises
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • data-networks-webdata-networks-web
  • lab-exercises
  • Wiki
  • lab 17

lab 17 · Changes

Page history
dmcqu009 created page: lab 17 authored Mar 01, 2016 by Dan McQuillan's avatar Dan McQuillan
Hide whitespace changes
Inline Side-by-side
lab-17.md
View page @ c278df95
......@@ -31,14 +31,11 @@ include_once "controllers/blog.php";
We want the public homepage to show a list of all blog entries found in the database. We will display the title, the first
150 characters of the entry_text, and a Read more link for each of the blog entries.
* declare a new method in the Blog_Entry_Table class.
* use PDO prepared statements for the sql
* use the 'try/catch' stucture when executing the query
* SUBSTRING() returns a part of a string, so to return only the first part of the entry text, your $sql will look like
* what does the 'AS intro' part of the statement do? satisfy yourself that you know (i.e. you remember the idea of an alias from term 1).
```
"SELECT entry_id, title, SUBSTRING(entry_text, 1, 150) AS intro FROM blog_entry"
```
we can use the same getAllEntries method that we created for step 2.
because of the way we wrote that, we can make use of the substring.
SUBSTRING() returns a part of a string, so to return only the first part of the entry text.
what does the 'AS intro' part of the statement do? satisfy yourself that you know (i.e. you remember the idea of an alias from term 1).
## blog controller
......@@ -146,5 +143,4 @@ i.e. inside the $entryClicked loop, you'll have
include_once "views/entry-html.php";
```
check this works ok.
check this works ok.
\ No newline at end of file
Clone repository
  • Home
  • lab 1
  • lab 12
  • lab 13
  • lab 14
  • lab 15
  • lab 17
  • lab 18
  • lab 2
  • lab 20
  • lab 3
  • lab 4
  • lab 5
  • lab 6
  • lab 7
View All Pages