PHP Solutions

Chapter 14

The theme of this chapter is solutions to common PHP/MySQL problems.

Solution 5 had no exercise and Solutions 6 and 7 were alternate methods of database interaction.

Solution Index

Solution 14-1
Displaying the first two sentences of an article
The MORE link doesn't work yet. If there are no articles, go ahead and make an article.
Displaying the first two sentences of an article
The MORE link doesn't work yet. If there are no articles, go ahead and make an article.
Solution 14-2
Foramtting a MySQL date or timestamp
Changing the default MySQL timestamp to English.
Solution 14-3
Displaying items updated within the past week
This should limit the articles shown to those created within one week from whenever the page is viewed. As I do these excercises practically at the same time, I won't know if it worked for a while. MORE link still doesn't work.
Solution 14-4
Validating and formatting dates for MySQL input
This is a script for creating the correct MySQL format for dates.
Solution 14-8
Adding the image foreign key (PDO)
Click EDIT and select an image. I've changed the list of entries to reflect the current image ID chosen.
Solution 14-9
Building the details page
Making the details page display both the article and the associated image. Click any MORE link to view its detail page.
Solution 14-10
Creating a link that returns to the same point in a paging mechinism
This is a little difficult to show that it's working. Basically, what happens is if you click a MORE link from a paginated segment of the journal list, it will return you to the same page when you click "Return to Journal". If you got to the article from a referenced link, then it will direct you to the first journal list page.
Solution 14-11
Inserting a new image with categories in a lookup table
The purpose of this easily insert an image into a database as well as adding the caption in one go. It gets the image from a folder on my site. This actaully works, but you have to FTP an image into the proper folder first, and I'm not going to let you do that.
Solution 14-12
Updating an image and its categories in the lookup table
This has no exercise.