- This topic is empty.
June 30, 2013 at 5:13 pm #45984
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?
Also, I hope I’m not exposing any sensitive information here. Please let me know if I am.June 30, 2013 at 5:43 pm #141067
Damn it. I thought it would be easier to understand than all of what you just said.June 30, 2013 at 5:57 pm #141070
@CrocoDillion I have many questions.
But first, in PHPMyAdmin under localhost->db-name, why is my database collation set at `latin1_swedish_ci`? I should probably change that, yes?June 30, 2013 at 5:59 pm #141071
you should have:
id – tinyint(8), primary index, auto increment
url – varchar(250)
title – varchar(250)June 30, 2013 at 6:10 pm #141073
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.June 30, 2013 at 6:27 pm #140926
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.June 30, 2013 at 6:34 pm #140927
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.June 30, 2013 at 6:52 pm #141075
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.June 30, 2013 at 7:02 pm #141076
@AlenAdbula What is confusing me is the way you were explaining it. The image helped a lot.
I won’t be needing a `user_id` since there will only be one user. Do I still need to set one for myself? Seems kind of unnecessary.June 30, 2013 at 7:10 pm #141077
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 ;June 30, 2013 at 7:12 pm #141078pixelgridParticipant
your table should have a primary auto incrementing integer id two varchar for url and title. just set a length for those and you shouldnt have any issues.
no need for user id if you are the only userJune 30, 2013 at 7:19 pm #141080
Now I’m confused again. Should I be using `latin1_swedish_ci` or `utf8_unicode_ci`?June 30, 2013 at 7:26 pm #141081
@pixelgrid @AlenAbdula So my table should look something like this, correct?June 30, 2013 at 7:31 pm #141083
@CrocoDillon Just read that! Thanks for the info.
I really appreciate all the information everyone has given me. Thanks for helping out and teaching me a few things.June 30, 2013 at 7:34 pm #141085
Yeah ignore that part I quickly generated it here on my machine. Go with whatever you need.
- The forum ‘Other’ is closed to new topics and replies.