8.4. Storing and Retrieving Images from the Database

If you need to, you can store the image itself in the database as a BLOB column. However, it's much more efficient to save the path to the image in the database instead. This means you need to do three things to save an image:

  • Add an image column to the entries table

  • Modify update.inc.php to save the image path along with the rest of the entry

  • Modify retrieveEntries() to select the new image column

8.4.1. Modifying the entries Table

Your next step is to add the image column to your entries table. You do this the same way that you added all the other columns to your table.

Navigate to http://localhost/phpmyadmin, open the simple_blog database, select the entries table, and open the SQL tab. ...

Get PHP for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.