hey guys my name is Sandra welcome back to this tutorial in this tutorial I wanted to teach you how to make a posting app using PHP so this by no means is just a video about showing my skills but this was what I built when I started learning PHP so I learned this using a tutorial by following tutorial but I did also add my own elements so this is how it looks like this has full crud functionality create read update and delete so first we could add a post I'm gonna give this a title post for I just made that styling little bit big so it's visible for the video image URL I don't need any major others so author I could say times a garage for the body of our gonna say come so the fun is just because you don't take care of that so now we have created their so here as you can see it only sub strings I mean posts a little bit so you can read that by click on read more so it's gonna show it and now we could edit it I could change this post for and it would change that we could also delete it so if I click on delay it's limited so we have the home and it's kind of in Egypt is a project but it was a competitive as a beginner for me to so I just wanted to make this as a tutorial so I could reread relearn it as Travis media said and this could also help be helpful so I'm gonna create a new folder by the way I'm using exam as my local server you can use anything I think everyone uses exam so I'm gonna make a new folder in htdocs' or host app I want to select that folder so inside that we are gonna be having all of our elements like the database connection and all those kind of stuff so once we do that we want to make database and get some data inside because we just don't want to have an empty post website so we want to give some data in it before we actually start making the connection and also not the database first and all right the second time so is running it usually comes faster by so now the which me my admin is working so I wanna create I'll just zoom in so I want to create a new database by clicking on that switch so the database name I want to give host app I want to click on create that's gonna create a database for us so as you can see it's named forced app so here I wanna save forces this is the number of columns that give their giving so we need four means six columns for the title body ID description here died I think it's five five four oh four five I think it's five when we create a table we can give all these stuffs so ID is gonna be integer we don't give a length so we don't want to be null we want it to auto increment which means that we will add it by to Auto increment the program once we add a post once we add a new table using a connection it auto increment one two three four we don't need to insert anything so once you click on that we are making it the primary key so it will be access it so here we need to define the title it's Warshaw which means it's a variable character and does not be the middle over there so title author and that's also going to be a watcher basically most of them are gonna be a watcher so title author and body body meaning the stuff that we're gonna put into it so text we don't need to set a length of length so here we need a creator which means we need a time step timestamp at which we created it so you go down here on the date and time it saves time stamp and under default you want say current timestamp and basically it yeah so for the come to see it's gone process and then wanna finish everything and we're gonna insert some data so as you can see we have a force table and said that we all these stuff so we want to insert some data by clicking on that so here we have the table so click on insert so I'm gonna basically and said so we don't need to touch the ID because it's our increment so first time Jairaj the title is I wanna say post one all right just give my name this is post one so the current timestamp is going to be a function which will take the current time step so the second one also we don't want to touch that so so come on I'm gonna put grad C which is travel medias name that should be not as well title is post too so the body I'm gonna see this is post sorry force to so I'm also learning so sorry if there's any mistakes so if I click on go it's gonna do everything and create some data for us so if go browse we would have data in up table let's can see Santa Raj and Brad table see all this kind of stuff if I'm going too fast I'm so sorry I want to finish this video as fast as I can yeah so that's it so here but here IDs 1 and 2 it's or incremental PA to dad and it's worth the time set so now that we have done with there we want to make the connection so I wanna open up so I open up a new and open up a new folder called config and inside that we would have DV dot PHP which will contain the beneficia so con which is going to be including the connection so you want to get that HP stuff first so make that connection con equals mysql i underscore connect so inside that we are gonna put all the values but before that we want to make a file that has all the stuff in it so a variable would help us use everything so inside this I will have confidant HP the zoom in a little bit so it's easier for you guys to see yeah that's too much and I think that's the same but anyway we'll make some variables so we don't need to be defining it as Springs and all those kind of stuff so I'll say define that takes in a function the name I want to say is database post which is the host I'm using is low curve post I wanna get this a couple of times down the before DP username and the password so here is user sorry database user so database password I'll just read you the best DB class so database name so database user is going to be root sorry root I'm not sure if possible but I'm sure you can set a password but database name is host what is the name before forced app host app so we have also done that so once we go there we could flow rate or we could wire it anyway config dot PHP so much while I connect now we could give DB posts what standing in maybe user DPD roots and we name basically we are passing in all the parameters actually localhost root no password should be the password I'm sorry no password and the name of the database and that's the usual way we connect but there is a way PE HPP Depot which is a secure way of connecting it which is object oriented so so we want to return the error if there is Error in a connection so MySQL I connect L know that that's a function so you guys an error meaning the connection has failed and we wanna echo fail to connect and we can basically concatenate it with the error so we could get the current error or no so the connection is done so we could open it in the local force to see it this is shot many errors so doctors post / course app so I don't think we'll get any error Davida yeah so we don't have any error so now we have done that you're gonna never doing anything or which is basically not good so we need to display the post so I a I'm gonna make a index dot PHP and the PHP tags and inside this they're gonna fetch the data so what I'm gonna be doing is first I'm gonna require the database connection first and because we need the connection so it sits inside conflict and DV dot PHP so now we have access to yeah so we want to quit she left from posts we're select from posts I'm sorry select everything from force to select everything from force so that's our query [Music] but we want to do is we want to get all the poses from the quay hosts equal mysqli I'm sorry it's my square I face all and we wanna party and the connection so basically give me a minute I'll just go and come back so I want to change the name of the post to be actually label course now about one thing I want to make the results and I want to make the result that SQL query query and only here we need to pass in the connection as the first parameter and then the query that's done we need to make an adjustment here you need to make it must rely a source which means we're gonna put it in an associative array which is which is like this name equals GN slide that so we can access it through that so now we are going to pre the result and we are going to close it close the connection and so if we check it we shouldn't get any errors which which shows that we don't have any original code which all expects there's some problem there thing yeah I stir we should get the result yeah that's working so after that we wanna put it in put it inside the application working application so first of all tell me just a blank HTML with web page so I make a div with a class of container and then I'll have an h1 but before that we want to make and PHP tag because there are a lot of I mean at least two uses and posts in the database so we need for each which means that for each posts as post so each post by defining it as post so reduce that and we end for each here so inside this we could give any code for single post any single post this would contain that sir dot contain inside so I wanna have an edge feature which contains the title of the post it's an associative array so I could get it like this I need a small set which will contain the description then we either have the author so I would say PHP course we're defining it has post because we are accessing the individual posts so what we do to the body see if there is like hundred words of text in the body we can't put the whole thing in a small tag so what I thought was to substring this between that function which like you say from 0 to 25 so which means that we want to take whatever it is in the body so we want to take the element that is from 0 to 25 and then only display that we don't want to display all 10,000 values but only that we need a P tag right now I'm gonna say PHP echo and I'm gonna pull out the creator net and the author so yeah I would say we eat pie and when I call out host author on and now will it go out force always forget that created act so it should work so basically we are putting the title on top for each post we gave the title so substring and then the other so now it should be working yeah another is what yeah so we have post one post to created by Sanjay Raj that's the first author name then Brad Travis it as a second one then we have everything so this is post one and this is post one which is post to if you can see we have the numerical number here and we should have it here to here so we have sub sprinted so if you zoom in you can see we have substring it and I have it this amount so I think the video is going to long so I'm gonna call it right here and I'll make the next functionality which is your read we made the read but where you have to create a create functionality in the next video but before that let me just make read more read more link so which basically says read more so this is wanna take it to an individual post dot PHP and we are gonna send the ID as the parameter which means we wanna we want to know or what host is clicking on we can't put every each statement or switch case statement for each of them so we send the idea in the parameter so we can access it in the post or PHP and get the current click so we want to echo out the post ID which were basically I'll just show it to you the how it works this is post one and this is post too so post one has an ID of one and post or society of two ladies for me it's post so if I click on read more the link should be host of HP and ID equals one yes you can see we don't have the file yet created so object not found ID equals one but if I click on click on to force to it should say ID equals two so that's the way we are gonna get the current post so yeah that's the way you do it and I'm gonna end it right here hope you guys enjoyed it this is just a quick way of doing it so hope you guys enjoy I'll see you guys the next one bye