First, I’m trying to store the `url` and `title` into a database from my “Read” section. I’ve created a database, database user and set a table with the name `read` with 2 columns (one for url and the other for link). This is where I’m stuck. I’m not exactly sure what I should put inside some of the options shown below.
Or should my PHP be setting this information from the array?
How is this table related to other tables? do you have users creating url’s and title’s? you might want to add user_id as well so you can relate(join) two tables if you ever need to display more complex data. `user_id` would be the id in the users table for example.
I’m not sure why I should set an ID? What’s supposed to go there?
No, the only “user” would be me. I add what I read to my readability account and pull that data from the RSS feed.
I’m just trying to store that data in case I decide to do something with it later. Something like show what all I’ve read throughout the year. As for now, I’m just going to be outputting my latest article that I’ve read.
ID is your table index, every table should have it.
This number keeps track how many different unique entries you have. It starts at 1 and with every entry it auto increments. In the example you have how would you display ascending or descending data? You would only be able to sort it by url or title.
In your use case you would only have one user id = 1 and the table read would have all user_id fields with value 1. The id’s once you set them up they auto increment, so there’s no need to pass data to it. You would only pass user_id value of 1, then title and url.
I would, so if you wanted to add extra info about the user down the road that data will be abstracted. Since you are the only user just pass 1 to user_id. or if you want to keep it real simple just add id (index, auto increment) to the read table.
CREATE TABLE IF NOT EXISTS `read` (
`id` tinyint(8) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`url` varchar(250) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;