Codeigniter CRUD Application with Bootstrap

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
assalam alikum friends and subscribers this is Mam shik and today I'm going to start a new video on uh developing a CR application using code ignor and bootstrap I have already downloaded a series on developing a c application using uh cordinator and Bo app but due to some problem with their audio quality I was getting lots of uh comments uh saying comments regarding the audio quality of those series okay that's why I have decided to create uh the same video once again uh where you can get where you can get a video with better voice quality and you can understand better um and you can learn better okay so here I have created that application you can see uh I have options like adding a blog post uh viewing that post updating that post and then deleting the post okay so these are the basic functionalities of any CR ification if I want to add a post then I just have to click on this add post button so if I click on that button you can see I have a text box and a description text area in this I will type a title and then I'll will copy that text and then I will paste it here and then I will click on submit uh now you can see that post is displaying on our index page okay if I want to add an and same time you can see a message saying that post added success successfully is returning from the server if I want to add another post I just have to click on ADD post and then just have to Angular JS and then just select this content I paste it here now if I click on submit you can see and another post with the title angularjs and a description is been uh displaying on our front page okay uh if you want to view that post you then you just have to click on this view button then you will be redirected to a page where you can see that post you can read that post completely in a full uh format full page format okay here date of published is also displaying so there's a button called as black if I click on that I will be Reed to my index page if I want to update any post then I just have to click on the update button of that post then I just go to type let's I'll just add some text and if I click on update you can see that framework will get added to the title of my post okay this is how we can update the post if I click if I want to delete any post then just I just have to click on this delete button and my post will get deleted if I further want to delete and another post then I just have to click on this delete button um that post will get deleted from my uh index page okay so this this is the complete functionality that we are going to learn that is that we are going to learn how to develop this kind of functionality using code ignorator and bstp okay so first um in order to start developing this C application using cordinator and boep you just have to go to your browser and then you just need to download codor here I have downloaded a codeignitor version I have codor 2.2.6 version with me I have downloaded it from the net you can easily download it from the net uh okay once you downloaded it then you just you need to go to your C drive inside C drive go to Zam and inside Zam go to S do and here you need to paste that project okay here can see coding 2.2.6 you need to copy this folder and you need to paste it inside your s do I already copied here I have given it a name as code igniter you can you give it a name whatever you want I have given it a name as a coding okay now once you moved your folder when you open that you will get you open that folder you will get some list of folders okay so now next step is to download or uh bootstrap files okay I I'm using bootstrap framework for my front end um so because I don't want to write all those HTML and CSS CSS CSS styling by by my own I just have to take that data that markup from bootswatch okay so you need to go to bootswatch and then once you are in that page then scroll down and go to theme paper okay here you can get a uh download link if you click on download you will get all the um if I click on this I'll get a file uh with a name called as bootstrap.min.css okay you just have to copy this entire text copy and paste it in your editor and give it a name as bo. me. CSS okay you can either download bootstrap.min.css or bootstrap.css I have downloaded bootstrap.css okay uh apart from that you need to download two more files which as GS files which you can see here here this is the bootstrap.css file which you can download from the bootswatch decom which I have shown just few seconds back and JS files bojs and jQuery 3.1.0 okay these two files you can easily download it from the net on once you downloaded these two files you need to create a folder with a name called as assets and inside that assets folder you need to create two subfolders with a name called CSS and JS inside CSS create uh save that bootstrap.css file which you have downloaded from here okay you can see you have downloaded if you click on this bootstrap.css file that file will get open then select the entire text and then paste it inside your text editor and save it to the name called as bootstrap.css once you are done with that copy that file or paste that file inside your assets folder and inside assets make a folder CSS and then paste it here okay and then do the similar kind of thing for JS keep your all JS files inside uh JS folder okay once you are done with this okay copy copy this folder by pressing contrl C and then come here and then click on come to your HD docs and open your project and paste it here okay now you are done uh of downloading codor and bootstap okay and now you need to come to your browser and type in 127.0.0.1 slash code igniter okay you need to enter the name of your project which you have moved inside your do folder which is code ignor in my case I have given it a name as code ignor so I'm referring with that name in my browser 127.0.0.1 codinger okay once you see that message that means you have done so far you have done everything correct okay so you are good to go ahead now once you are done with this you need to uh open your editor okay you need to open your editor and then click on file and click on open folder and then go to HD Docs and from here select the folder which you have moved inside your H do I have my project name is codor I will select that folder and okay that Pro that my project is been now open inside my editor and now if I click on applications I'll get all the files and folders and you can see I had pasted on assets folder and I have uh that folder is also displaying inside editor with the files called boot. CSS and boot. JS andj 3 .js okay now we need to start uh writing in or or typing in our or building our application okay first uh we need to go to our browser and type1 127.0.0.1 slash PSP my admin okay we need to create our database first okay first we need to create our database uh for our application okay I'll click on databases and give give a name to your database I'll be giving it as code igniter I'll just click on create you can see the database has been created now create a table inside in that table I'll create TBL post with four Fields one is for ID another one is for title for third one is for description and fourth one is for date okay so I'll be creating four Fields inside my table I will just now I'll click on go okay here ID title then description and then date created then select a data type as date for date creation and then description for description I'll be using text I'll be using Text data type and for title it will be uh Vare and ID it will be integer so let's okay here and then now click on auto increment set it as a primary key and click on go and now come at the bottom and then click on Save [Music] okay now we have created a table now we need to go to our datab to our editor and inside our editor we need to go to our application and inside application click on config and from here we need to set our database configuration settings uh now we need to click on database.php here you can see uh here we have an options or a database configuration settings 127.0.0.1 and then username root password is empty and database is code igniter okay and this is the database which you have created just few seconds back you can see database name is code igniter code okay database click on database here code ignit okay everything is fine okay now we need to close this and again we need to go to our autoload we need to first we need to load our libraries we will be while developing this application we'll be dealing with the databases sessions and form validations okay so before developing before creating our application before start developing our application we need to set our libraries first okay since we are developing a database application so we we need a database Library I'll just copy this and cck it here and we will be dealing with the session also to display appropriate message to our user uh whether the post has been added whether the post has been updated or whether or whether the post has been deleted or not for displaying those messages we required session a session flash data so I'll just copy and paste it here and we need one more Library which is form validation Library okay form validation library is used uh to display the message to the user whenever user tries to submit the form without entering anything on the text boxes okay at that time we can we should display the form uh error messages uh using the form validation library now we are now again we we need to use helpers we will be uh we will need we need helpers so I'll just add those helpers after words so that you can get uh a better idea what will happen if you don't use those helpers if you don't mention those helpers in your autoload.php file okay so I will just come back here afterwards when I get the error for that and then now we need to go to routes okay this okay I'll be using a welcome controller and then you need to go to config find encryption key okay we need to set the encryption key 1 2 3 4 5 6 7 8 9 okay now save it close it and come here click on controllers and then click on this okay and open your view welcome message and now delete this entire CSS I don't want all this CSS and here we need to call our JS files script Source equals to HP Eco base URL and we need to pass the path of our GS file my GS file is inside where it is here inside assets folder B your B URL will return you the path till this folder 127.0.0.1 cinat this is the base URL after that we need to type uh the folder structure by our own okay inside our project our uh CJs files JS file is inside uh assets folder inside assets there is a folder called as Js inside JS folder we have a file called J bojs and jquery.js so we need to type in assets sljs SL bootstrap.js okay now we need to do the same thing for jQuery file jQuery 3.1.0 DJs okay next we need to call our CSS files here PHP Eco base URL and then assets SL CSS SL bootstrap.css okay now let's see whether uh we can access those JS and CSS files or not to check you need to right click on the page and then click on view page Source then you can see it's uh showing you an error called to undefined function base URL okay this is showing this error because we have not used uh helper of coordinator helper which is URL this is what I was talking I was talking about when I was discussing uh in about in autoload okay uh here I have not you call a URL Helper and we again also we need a form helper okay so uh this kind of error will be shown to you if you don't use URL helper in your autol PHP file and now if I refresh you can get uh you can see the that error is no longer uh displaying okay now you can see all the links is are displaying which are I have created here okay now if you check if you want to check whether your project is referring to these files or not you you just start to click on this links okay my file is loading okay this one is also loading and the last one is also loading here okay now I'll just okay okay now I don't want all this thing also just delete this delete this complete du okay now then I will go to boot swash website and and I will go to click on preview and here you will get all the necessary design templates uh for your web side or your portal development see you can see there is a code for neobar buttons typography tables forms okay I want uh navigation bar now I will just click on this na bar and if I click on this link I'll get all the necessary code to create a navigation bar I'll just copy this code and I will paste it here and I will delete whatever I don't want I don't want all this I don't want this one also okay 4 C application with Bo Tab and now I will now if I come to my site and if I refresh you can see uh a navigation bar is displaying I want a footer also so what I will do okay I will copy this again and paste it here as a footer okay just delete this okay now uh I want a table for that again I will go to boot Swatch and then here I will click on tables I will get a table section and if I click on this icon I get the code for the table I will select the entire code copy and I will paste it here if I come to my browser okay table is displaying here okay now I will uh Delete the rows which I don't want in this table okay I'll just keep only one row save it refresh okay now I will put this table inside a container so for that is the table here from here it should start a table and end it here okay and okay let's put it inside a container class container okay now you can see uh I'll get a margin from both the sides okay that's fine now we will use an H3 tag view or post okay it's showing a message saying that view all post and I want a button okay here just below this uh text view all post I want to display a button with a name called as ADD post okay for that you need to go to your codeignitor guide 127.0.0.1 SL code ignitor slash user guide okay so coordinator has uh provided you a facility where you can uh eval each project the project that you have downloaded from the net will come with your user guide okay so to refer to that user guide you need to go to 12.0.1 cinat which is your project name/ user guide okay here if you click on this table of contents you will get a list of all the uh topics or the concepts in coding ner okay now I want to display as I said before I want to display a button okay I can create that button by using an input type button or input type or button uh input type equals to button name goes to submit kind of thing okay using HTML input tag uh HTML tag uh uh but coordinator has given you a facility by which we can use coordinators uh classes to create a button okay for that you need to click on form helpers and okay you need to go to table of contents in url helpers I want a link instead of button I want to keep a link here okay for that you need to go to URL helpers here table of contents and then click on URL Helper and then scroll down and then you will get a uh TI as a uh label as anchor then you need to select this copy this and come here PHP okay [Music] then welcome and here let's put it inside an array as name okay here class as BTN BTN primary and comma add post okay save it and refresh okay now you can see there is a button with a name called as ADD post if I click on this it will go to welcome which is here okay here we need to Let's welcome slash create okay now then it will go to here inside welcome controller and there has to be one function with a name called as create okay create now if I save and now if I click on this add post it will go to that create function inside welcome and display the appropriate message okay now uh I need to uh add some action buttons here and at the same time I also want to change these headers of my table so for that I'll go to welcome and this will be the title and this will be the description and created creation date and then at the end action okay now here we need to create Three Links exactly similar links copy P here and this one is for View and change the label copy this couple of times second one is for update and the third one is for delete update and delete okay for this I want to I want I don't want to give this these kind of styles to my uh links if I come to my site and refresh you can see this kind of style is is there for my buttons but I want to change the style of these buttons so I'll go to wwatch okay if and I will scroll down further and okay here we have okay I'll just click on this icon and I will select this class okay here to paste this I'll make it as primary copy paste it here again paste here and this one is success and the last one is danger for delete you know if I refresh my page okay you can see the style of buttons have been changed now and now the next step is adding some text uh inside my database and displaying that post in the uh in my front page okay for that I need to go to database and I will make uh I will enter one record inside my table okay coding here the project sorry coordinator is the uh database which I have created for this project and there is a table with the name called TPL post and I will click on that post or open that post table and click on insert I'll type title let's say word press WordPress tutorial let's say okay I'll just select any date and if I click on go that record will get added to the table okay now I will uh fetch this record and display it uh I will fetch this record and I will display it on my uh front page okay for that I need to go to models and I need to create a model right click on that models and click on new file and uh save it with a name called as queries. PHP remember you need to give it a name uh for your models with your your models should start with the model names should start with the smaller letters okay save it and here inside this inside your file you need to refer to those files by starting the name of your file with the capital letters PSP okay class queries extent C model okay now we need to create a function public function get posts okay now we need to get all the posts that are stored inside our database so to for that we need to go to our coordinator user guide and here inside table of contents you need to go to database classes inside database classes you'll get all the uh details all the stuff related to your database activities okay go to database classes and then click on active records and then since we are selecting the data right now we want to fish the data from the database that's why here there are categories uh selecting inserting updating deleting and Method overriding and AC caching now we are our major concern is selecting the data from the database so we need to click on select data so here we will they have given us a query with the help of which we can get the data from the um from the database okay now let's copy this and come here and paste paste it here and change the name of the table to TBL post tore post and uh use an if condition to check whether uh we are getting any records from the database with this query or not okay so I'll just pass this query num row greater than zero okay here we are checking uh whether uh this uh this sh m is returning any records from the database or not if this query is has returned some data if this query is having the number of RS greater than zero then it will return it will return dollar query of result okay save it and come here and inside our index next function we need to call our model so the way of calling a model is dollar this load model okay we need to pass the name of our model the name of our model is queries okay and we have a function with a name called as uh get post here we need to call this function inside our uh index with the help of queries color this queries dollar post equals to uh okay we are calling a function which we have created inside our model name uh get post we we have created this get post function to get the get all the records from the database or get the all to get all the post from the database so this function will return the records and we are using this function here inside our index and all the data is been stored inside this post variable okay so to check that need to use a print R function copy this and paste here EO three copy this past here okay now exit now it should return as the the data which we have saved inside our database so let's go to our our homepage and refresh you can see uh this is the record which we have saved inside our database WordPress WordPress tutorial okay so it has return us the record uh which is stored inside our database with the help of this function right now now we need to delete this and copy and pass this to our view as an array okay uh we have created an array with a name called as post and to that post array we have assign or we have set our all the data which we have F from the database so that we can access that data inside our view inside our uh home inside our hom page here we can access that array okay so before that I just need to uh create two more View files one is header and another one is footer create a new file and save it with a name called as reader. PHP and one more file with the name called as voter. phsp okay now let's take this entire stuff cut and paste it inside our header.php file and this one cut this out and paste it inside our f. PHP okay now we need to call these files PSP include once okay sorry it should be footer. phsp copy and paste it here change it to trer PHP okay now if I refresh uh okay nothing has changed okay that means it's perfectly fine and since we have now we have fed our data from the database and we have sent uh that data to our view welcome message uh by with the help of a array okay now we need to use this array inside our uh inside our welcome message now we need to okay here enter and use type PHP if count of post sorry if count count of this this array copy and paste it here if count of this array if you are having any uh result or records coming from the database PHP else and if okay if you are having any record then we'll be displaying those records otherwise we will display them a message saying that no records found okay and then if we found if we um if the database has return if this queries function has returned any rows from the database if if this function has return any post from the database then we will uh display those post with the help of for each Loop PHP or is dollar posts as dollar post and then PSP and for each okay now we need to use this dollar post and here we need to PSP Eco dollar post of title copy past here with this title and this one is description and the third one is what we have in our database third one is date created right so this should be date created okay now save it and now if I refresh the page I should get a first post displayed on our homepage okay there is an error welc come message 27 and for each okay okay here there has to be column now if I refresh you can see uh the first post is displaying on our homepage okay now uh the next is to create a post to create that blog post if I click on this add post I should get a form where I can write a title and a description and if I save that post should display here on our uh on our homepage so to do that you need to go to views and create another view file with the name called as create. PHP okay now PHP okay copy this and paste it here and one more time change it to footer okay and need to create a du with the class called as container save it and go to wotw and we need a form we need to create a form uh so in boot we can also get a form okay here it is just go at the top and you will get a link to forms and the click on that you will get this form click on this icon and copy the entire code okay yeah copy this code Okay contrl C and come here and paste it here and save it and let's Okay we to call this create view inside our controller so here I'll just copy this paste it here I will delete this change it to create okay now save it and refresh if I click on ADD post I'll get a form like this okay now I need to uh Delete the stuffs which I don't want in this form okay so go to create form and delete this okay uh let's change the columns I want my a layout to be medium not the large so wherever there is a layout with a name called as LG I change it to uh medium find replace so I'll just change it to LG2 medium replace all okay save it and change it to title okay and then okay we had a text area also here which I have deleted okay now I want that and go to find click on replace okay replace now change it to title copy this paste it here and then this one should be description copy this and placeholder past it here and delete this span okay okay title description here I want to uh decrease the size of my text boxes I want to make it as four or let's say five okay and I want one more do to display the errors I'll just copy this once again and save it okay this much is fine and then here you can see uh here it is input text boxes and uh text area is in HTML format we want to replace it with our code ignitor code ignitor input and text area so for that we need to go to our coordinator guide click on table of contents and then click on form helpers and here you will get a uh element for form open control find form okay here it is form open I just copy this and here paste it out here and welcome SL save okay we need to create a function with the name called a save inside our home controller we have not created yet we will create it very soon so and uh class we need to create an array to mention the class class is this one copy here and UT name okay I'll just delete this and I will delete this form also here I will use an form close method EO form close okay now save it select this save it and we need to change this input element with our coordinators in in form helper let's come here and look for form input okay here it is okay select this copy and PP okay here paste it out Del it okay inside it create an array so one is for name title then another is for Des sorry one is for title and another is for placeholder and the last one is for class class will be this one form control copy this and paste it here save it and if uh and just copy this once more time and paste it here and change it to text area change it to description copy and P it here okay now delete this and if I come here and refresh the page okay again I got a title and description uh text area and similar we need to change this button also we need to go to here and look for form submit okay okay here we have that copy this paste it here okay I have pasted the code for creating the forms uh form submit and I have created an anchor and to that anchor I have passed uh URL as welcome so that when I click on that back button I should go to um homepage of my uh portal or my blog so I will just refresh refresh I'll get a message saying submit and uh back uh if I click on back I'll be uh redirected to uh my homepage okay now we need to click on ADD post again and we need to uh write the functionality for adding a blog post so uh whenever uh user click on this submit button it should go to save function inside the welcome controller okay we need to go to our save function inside welcome we to create that function public function save okay need to do some uh form validation for that we need to go to our Cod inator form sorry coordinator user guide cck on table of contents and then click on form validation class then click on form and here you should copy this line of code and then paste it here okay okay so not this one actually this one copy this and paste it here and delete this to this one also save it okay here you should enter the name which you have uh name fields which you have given to your input and uh text area first one is title and next is description okay now here success and here should be eal validation errors okay so here I'll take the values uh that has been entered uh if this title and description refers to the uh values those values which user is going to enter inside this text box and inside this uh text area okay if the user uh if user enter both text both title and description values then Eco success will display success message will display if the user click on submit button without entering anything in the text and description uh Fields then we will get a message uh saying that title is required and description is required okay so let's check this out refresh and if I click on submit I'll get a message saying that the title field is required and the description field is required okay so now let's now copy this it here and let's go back to our formal relation okay scroll down okay let's come here to our now uh if uh if user uh tries to click on submit without entering in this text box and in this text area then it should display the message just beside this text box and text area for that we need to go to create and here we need to type in eal form error okay and then we need to enter the name field which is the title copy this paste it here comma and and do with the class text danger okay copy one again copy this paste it here and change the name to description okay now save it and refresh and now if I click on submit it displaying me a message saying that that field is required and description field is required okay previously it was moving to the next page and it was displaying there now I have set it to display it on the same page and now we need to write the code uh to save the data whenever the user click on submit button okay so for here we need to write that code first we need to collect the data which the user is going to enter inside the text box and text area for for that we need to type dollar this input post okay now this data uh variable will hold all the data the what user is going to enter inside this form so we can see that data this by using print R and passing this data array or data variable in set this Sprint PR copy this and exit Okay save it and if I refresh now if I refresh and type code ignitor and here C matter tutorial if I click on submit now you can see the data that is uh uh is displaying whatever data I enter in the text box and text area the data is displaying here in this array title description and along with that it's displaying a submission also I want to get rid of this submit equals to submit okay because if if I keep this uh extra information inside this array uh then the data will not get saved so we need to remove this from the from our data so to do that we need to go to our editor and type unset and then this data of of submit okay now save it and refresh okay now if I type code igniter and code ignitor okay if I submit now you won't get that uh extra piece of information coming with your submission okay now we need to remove this code and we need to call our model this load model this queries okay we need to pass this queries inside here this queries then add post function we need to create an add post function inside our model queries public function add post okay and this function will uh accept a parameter which is data uh that is coming from our form here we need to go to our form uh to our user guide and click on table of contents and then click on database class and from here click on active record class and here click on insert data and we need to use this line to insert the record in our database return this DB insert this TBL post and this pass this data okay now it will return a value of either one or zero one if the data gets saved successfully and zero if the data did not get saved inside the database or table okay uh now we need to accept that value which is coming from that function if this square is at post the function which you have created here returns a value of one then we have to display a message saying that record sa successfully or post sa successfully we can display that message using the uh set session flash method of session Library dollar this session and set flash data okay so this set flash data is a method of our session Library which allows us to display the message uh to the user only once when any submission is been made on the form at that time uh this we can use this set flash data to display that to flash the message to the user saying message and message is uh post saved successfully let's copy this uh failed failed to save post okay then return redirect I'll be redirecting to uh welcome controller in both the cases okay now let's come to our homepage and refresh the page and click on ADD post and now code igniter and then codeigniter tutorial if I click on submit now I got a message okay load on 38 of Welcome controller 38 okay load okay now save it coordinator and if I click on submit can see a couple of Errors undefined variable data you must set must use the set method to okay here what I have used insert okay so let get this D be insert okay data okay here here I have not passed the data to my ADD post function so let's now refresh and enter the data and if I click on submit now okay the data has been saved but I didn't get a message because I have not uh uh used this message variable inside our welcome message here we you need to use that message PHP if and if okay if dollar message equals to dollar this of session flash data of message okay we need to pass this message uh pass this message value uh here inside our inside our Flash and Eco this message copy and paste save it now let's refresh and click on ADD post angulars framework now if I click on submit I should get okay yeah I have made some mistake I guess okay this should be inside HP tax Okay now click on ADD post click on magent to Magento development now if I click on submit now you can see post successfully message is displaying and at the same time our uh data is displaying or post is displaying on the table but we are not getting this dat okay for that we need to uh do some adjustments here we need to come here inside our C function and we need to type yeah here okay now we need to create a variable with the name calls today and to that we need to assign the date today's date and the today date will be in the form of year month and day and now we need to pass this date inside our post data date okay copy this past it here date created okay we need to uh add this date inside our date created field of our table now uh refresh and click on ADD post then jumla development okay now if I click on submit you'll get a message post successfully at the same time I get the date also okay now refresh now we are done with our adding a post to the database now we need to uh do the same thing for update updating okay for if I click on update I get a same form I should get the same form but with this but that form should also contains the values like this title and description okay so for that we need to go to our editor click on views and folder and click on new file and save it with the name called as update. phsp copy and paste it here same code and and here we need to change it to like change this change function we need to create a name function with a name called as change inside our uh welcome controller okay public function first need to create a function with a name called as update to display that form copy paste it here and okay now if I click on this update link it will take me to the uh update form okay then add post and then here it should be update post okay now refresh and we need to display the values here okay from here okay double quote put these inside double quotes okay now refresh and go to home uh now if I click on any of these links okay I'll just resize this window okay now if I click on any of this link you can see on the left left bottom of this browser you can see a link saying that 127.0.0.1 cator index.php welcome SL update okay or SL view or SL delete okay uh but this is the uh link for this individual post this should contain this link should contain the ID or the post ID of this individual post so um so that when I uh put a mouse on this each of this link it should display me the ID of that individual post so for that we need to come here and we need to forward slash and brackets then we need to copy this paste it here and let's change it to ID copy okay now if I refresh you can see now if I keep a mouse on The View you can see the ID is also showing ID is ID is two and this ID is three ID is four ID is five the same is for rest of the but ID five id4 ID3 okay now if I click on this update it should uh take me to the uh post uh to this individual post with the ID of one so how I can do that so uh if I click on update it should go to uh update function inside the wel welcome controller here and display the uh update View and at the same time it should take the ID dollar ID okay and if i e dollar ID okay let's refresh and click on update okay the ID is displaying here if I click on to ID is displaying here which is this same ID to okay with the help of this ID uh I'll be getting the data from that uh data from the database of this particular post okay so I'll just now I C on okay here I have uh the same query also already available I'll just paste this here get okay now let's change it to get single post okay and pass this ID to this function and let's create this function inside our queries public function okay and we need to go to our database and here at the top click on table of contents database classes and then active records class and then click on select data and then select where okay we need to take this copy this and paste it here and change change the name to TBL post and and array ID is this ID and delete this we need to select the uh title description and date of creation of that individual post of that individual post whenever user click on this update button okay so now the same thing we need to copy P here instead of result we will be returning the AR row here I want a single from the database not the all not all the record from the database that's why we use row function now it will return that single Row from the database and here we need to receive that uh data and store inside this post variable so this post we need to pass to our update using an array copy paste change it to post okay now we need to go to our update and here inside this array set value as dollar post of title okay now let's see okay here value set value of of our post title now let's check title post title refresh and click on update okay or title is displaying and now the same we need to do it for our description okay description is also displaying Okay so what I have done is I have inside my queries I get the record from the database I fetch that individual record from the database whenever okay whenever user click on this update button which is here inside my welcome message uh whenever user click on that update button I'll be sending the ID from here uh using the get method the ID will be passed and that that ID will received here using the get method this ID will receive in this form inside the update function of Welcome controller here the ID will be received and with the help of that ID I'll be fetching a single record from the database here and I'll be returning that database and I'll sending I'll storing that uh record inside this post variable and I'm post I'm uh sending that record to my update view uh with the help of an array okay uh here inside that update. PHP I'm receiving that data okay now we need to create a change function uh inside our welcome function so that whenever the user whenever the user click on the submit button here whenever the user click on the submit button the record will get updated let's change it to update okay and need to create a uh function with a name called is change public function change okay need to copy the same data here also and title and everything is same but we just need to change this function update post post updated successfully failed to update post okay we need to create this function inside our queries public function paste okay now come to our uh user guide coding user guide click on update data and from here we need to copy this okay update copy and paste it here and it as return this DB where this ID where comma dollar ID where ID is the is ID then update copy comma dollar data update with the data okay now we need to come here welcome and we need to pass the ID we need to send the ID also okay so let's just first comment all this thing for better understanding here we need to get the ID of the record for that we will be going to our update View and here we need to put this inside the double quote and then put forward slash and from here we will be sending the ID of that post from the with the help of form uh with the form itself we are sending the ID so um this ID will get passed to change function which is present inside the welcome controller here inside the welcome controller inside this change we are receiving that ID now if click on if I write on eco and if I dollar ID save it and Okay click on back and if I click on update and if I click on this update you'll get a an ID with a which is one okay because this is the first uh post inside the database and if I click on this jumla and I click on block I will get the fifth ID so I'm receiving that ID here and this ID I'll be passing here inside the update post okay so that I can collect that ID here uh to here to update the post okay now let's refresh and jum framework okay now if I click on update now it uh it has shown me a message saying that post updated successfully and the post is also updated here okay uh so this is how you can uh create a functionality to update the post now the next is to view that post okay if I click on that uh if I click on this view button I should get uh uh different template where it's displaying me the uh that individual post for that we need to create a file with the name called as view right click on that view folder and then click on new and then save it with the file name called view. PSP and copy copy this putter okay now we need to use H3 VI post and then uh S three okay not H4 let's check H4 for displaying the post title copy P sorry P for displaying post title uh sorry this one is for title and this one is for uh description and this one is for date okay now we need to create this inside our welcome controller public function view uh and copy save it okay now let's refresh if I click on view it has taken me to that particular view where I can display uh the post details of this particular view now let's go okay here we already created a function inside our queries. PHP to get a single post okay the same function will be using uh to display the individual block post okay here you need to come here and copy this entire thing and paste it here okay get single post and we need to pass this ID okay let's comment it first and Eco dollar ID now save it okay so whenever whenever user click on this view with this view uh an ID will be passed where using get method which you can see at the left bottom of the browser welcome SL view1 okay this ID of one will be passed with the help of get method uh to this View and that ID will display here okay which I have printed here okay now I will receive this ID here and I will pass this ID to my function get single post to get that individual post and that post I will that post title description and date of creation will I will store inside this variable and I will pass this variable as an array to my view template so that so that I can um I can display uh that individual post details inside my view PHP okay here I will display this PHP PP eal dollar post of title copy description and then the last one is date created date created okay now I must get a record or a view uh to be uh will be displayed whenever I click on The View Link in homepage if I click on view I can get the uh record individual blog post okay so now I will I should display I should uh create a back button here so let's create that back button so just copy this and go to view and I will paste it here and we save it okay if I click on back I'll be redirected to my homepage okay now I am left with uh my last uh function which is the delete so if I click on this delete I should go back I should uh go to the uh Delete function inside the home inside the welcome controller okay which we have to create it now so inside welcome you can see there is a delete function uh that I have to create inside welcome controller and to that function I'll be passing the post ID so I should go to welcome public function delete okay here I need to accept that ID which is coming from the get method Eco dollar ID okay so now refresh if I click on any of the uh delete button of any of the post I will get the ID of that block post so I will use that ID to delete that particular post so just call this okay delete this delete post and to this function I have sent the ID which I have uh collected with the help of get method as soon as the whenever user click on this delete button here I passed this ID to delete post function which I have to create inside my queries to delete the record public function okay we need to go to our user guide and go to delete data and we need to uh write okay copy this past it here let's change it in a different let's DB uh this DB delete and I will put the ver condition inside here okay table name TBL post comma ID dollar ID okay now we need to come back here and we need to put this inside if condition because our function delete post will return a value of either zero or one okay here I have created a function with a name called as delete post and to that delete post I have pass the ID uh which I want to delete okay so this function will return a value of either zero or one one will return if the data gets deleted if the records get deleted from the table and the zero will get return if the delet if the record will not get deleted from the table so save it and else we need to use our this one session set flash data copy paste it here and then copy this paste it here post deleted successfully fail to delete post okay I will be in both the cases I'll beting directing the user to welcome controller okay now refresh okay now if I click on this first to delete now I get a message the post deled successfully and that record will get deleted from the database if I want to cross check I just have to click on TBL post they won't get a uh record with the ID of one now okay there is a record with the ID 2 3 4 5 but not one you know if I click delete I want to delete another record I can delete that also okay so this is how we can create the uh or develop a complete solution for crud uh for operation of crud using coding n and bootstrap okay so in this video or in this in this movie I have discussed complete in detail uh how you can download coding n how you can download WRA framework and how you can start developing your how you can integrate your wood strap with your codeing ner and how you can uh write different functionalities to perform different operations like how you can uh add a post how you can view a single individual post how you can update a single post post how you can delete that post okay so I hope you like this video I hope you got some useful information out of this C application code using cordinator and W step if you like this video subscribe to our Channel click on like button share it with your friends and I'll see you guys in my next video thanks for watching guys
Info
Channel: How to Make Tut's
Views: 75,180
Rating: undefined out of 5
Keywords: Codeigniter CRUD Application with Bootstrap, codeigniter crud application, crud applcation, database application, php crud application, MVC Framework, update, create, delete, read, blog application, blog post, insert, tutorial, learn codeigniter, codeigniter concept
Id: CiAm1rso1-U
Channel Id: undefined
Length: 92min 11sec (5531 seconds)
Published: Sat Apr 08 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.