So I am trying to create a blog in php and mysql. I am not sure how this is going to work out there. Just let me know if i am on the right track with the DB.

Let's say i have database called blog with table user and posts. This is for multiuser blog. So I want to connect userid with the posts table. So I need to make userid field common in both tables right?

e.g.

create table users (
id int auto_increment primary key,
userid int NOT NULL, 
password varchar(40) NOT null, 
)

create table posts(
id int auto increment primary key, 
userid not null, 
post_header varchar(400) NOT NULL, 
post_body text NOT NULL)
foreign key userid reference users(userid);

Is this a right approach ? Also I am thinking about making procedural way of accessing data with mysqli. Is there anything wrong with procedural approach?

Is this a right approach ?

Yes. But userid in the users table is not necessary. posts.userid should point to users.id. You can make it a foreign key if you like.

Also I am thinking about making procedural way of accessing data with mysqli. Is there anything wrong with procedural approach?

No, nothing wrong with it. MySQLi is the right choice, although you can consider PDO (but that is not procedural).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.