How to Filter Database Records using Textbox - Radiobuttons - Dropdown and Datepicker using PHP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- sim subscribers this is mama shake and in today's video I'll be discussing how to filter the database records based on different form elements here you can see this is our application which will be going to discuss which will be able to create in this video so here you can see I have taken different form elements like text box radio buttons dropdowns and then nitpicker okay so what I'll be doing is I'll be tried to get different records based on different selection suppose if I type like sewage and now if I click on submit then you can see I will get the record of sewage okay I will get I get that specific record from the database and now if I want to get some other record like Anita okay and if I click on submit I will get the record of the details of Anita and if I want to filter based on gender if I want to get the records in my database those hello if I want to get only the male candidates from the database then I just have to click on this male and I click on submit then you can see I will I will get only two records which are present in my table if I want to get details of female records then I just have to select email and when I click on submit I will get the details of only female candidates okay if I further want to filter based on courses okay here you can see him said this drop-down how taken be a become an BSC courses and if I want to get the records of those students or the users who have taken become as their course and when I click on submit then you can see I can get only the records of those students were taken become course okay if I want to get ba students then I just have to click on ba and I will get only their details of BS wails if I select BSC then I will get the records of B assistants okay if I further want to display the records based on dates okay from date into date let's see I will select this okay let's go back okay from here and let's take here okay from March to May if I want to see how many records I'm having who's having the from included between these two ranges then I just have to click on submit then you can see these are the records which having the from included between the dates of March and May okay so if I further go back to January if I select this and March okay March 31st now let's see see here you can see I am having only two regards between January 1st and March and ok so in this video tutorial will be going to discuss how we can develop this filter applications how we can use different filtration filtration using PHP how we can face that either based on different filters like with the text box with the radio buttons with our drop-down and with the date picker okay so we'll discuss how we can develop this kind of application in this video tutorial series okay so first we need to create a project so for that lets go to our exam inside I'm having htdocs food it's and htdocs' I will create a new folder with that name as PHP filters ok so inside this I will create a folder so before that I will just take this project inside my editor I will just come here and I will select open folder and I will go to htdocs then these P filters because my lips closed the previous one okay now here I will create few folders this a new folder I will create one folder for storing CSS files and I will create one more folder for storing J's files and then one more folder for storing my database configuration details and I will give it a name is config and I will create one more one file with a name called index index dot PHP okay so here we need to download CSS and J's files case of we need to ok let's first come here I mean here you can see I'm having folders and inside these folders already I have downloaded all the GS and CSS files which I have one for this project so I want push separate CSS file and jQuery UI dot CSS file okay so this jQuery UI dot CSS file is for displaying the calendar okay and I'm having a J's folder as well and inside this we want all the J's files boost approaches jQuery one point twelve point four J or dot J's and then jQuery that mean dot yes and then jQuery UI okay so now let us see how we can download all these files so far I will I will put the link of these files in the description of this video so now let's first come here and for downloading jQuery UI like this calendar you need to go to your browser and then type J query date picker in Google and then very first link you click on the very first link and then will be redirected to here and then click on this view source button again we will get this draw text box and just below that you will get this view source and then immediately this window will get open and from here what you need to do is we just need to copy this and code okay and then you need to put it here okay inside this address bar okay so when you paste that this URL into your and when you enter you will get this goal and then just select this entire code by pressing control a and then copy this copy and then paste it in your editor and then save it with a name called jQuery UI dot CSS okay so create a folder called CSS and inside that folder you just save it but I mean call jQuery UI rocks again the same thing you need to do for the rest of the files equally one point well point for not GS as well you just need to copy this to copy this and then you need to come to your browser window and then paste it here and then select it and then save it with a name called jQuery one point twelve point four and the same thing you have to do for this as well so this is how you can download all these files and for these two files Jay bouche f dot CSS and bootstrap dot genius and then this jQuery three point one point zero dot min dot J is for these files I'll put that link in the description below okay so now I already downloaded this files so what I'm going to do is I will just copy these two folders and just cut it out and then I will come here to my project here so first I will just move on I will just copy these two files and then I will come to my project PHP filters and then CSS and then I paste it here there's something a same thing I will do for J's paths I'll just copy this files and then I will come to my GS and then I paste it here okay so now I have move my GS and CSS files into my project folder so now let us come to our editor you can see here I am having all these files so now let's create this file type doctype HTML and then sgml okay and then title is filters in PHP then link okay and then for link I'll just link my sis file CSS Mujibur seizes warship rocks ESS I will just copy this and I'll change it to J query uy dot J's kids equally UI dot CSS okay now I will link my script J's files source inside this I will link these files the first file I should link is in jQuery one point 12.4 not genius okay so first first of all I should link this jQuery file and then I should link my remaining J's files and this one is whatsapp dot yes okay so if you if you don't use this boot several J's file it will not make any problem so I just believe that just JS / jQuery you are not yes okay and then Jess / okay so now I will link all my GSN CSS files and then I will just create one more script and inside this I will paste this jQuery code jQuery datepicker port will just copy copy and then come here and I will taste okay now I will just copy this once again because I want to display too deep because here okay so one this one bit bigger function is for first again and this second one is for here to date and now let's save it and then just make it us from and to ID okay so now let's come here and we'd do the class of container okay now let us check our application before shaking okay now I'll just close these tabs okay okay now it's like one 27001 slash finished feed filters okay now let's right click and then click on view page source now let's see our boots abroad see our CS and GS five seven link successfully or not I'll just click on it let's see okay sonar showing me CSS core and now let's click on this okay this one is also linked okay this is displaying this core as well okay now all my CSS and J's files are successfully linked to my application okay so now let's come here and then create a new you know without loss of neova me over and in was inside this I will create one more do with a class of container fluid okay and then inside a collar see okay it's displaying me the header and others display and s3 okay Oh to filter and of course using PHP okay save it and our let's refresh okay sorry annoys displaying me that title so I just need to change the color of that font font color color as white so now let's refresh hope it's not displaying with a title you know let's come here and start creating our form so for that let's come back and then create an h3 tag and then whoo right ESP filters let's see it refresh ok let's change in the styling style text-align:center it to the center okay and then found to wait I want to increase the font weight bold we how save it okay we are next is need to create a deal with the class of the row okay so all these classes are coming from bootstrap dot bootstrap framework okay so that's why we had used this booster or CSS file we had entered into this bootstrap would say that's fine so that we can include the classes of this satisfied because I will put the link of these files in the description below so you don't have to worry about these files how you can download this file so I will just put the links of these files and easily you can download all these files ok so now let's create the form and then plus form horizontal and then action will be the same file index dot PHP and then letter will be post okay and then we need argue with that loss of form group okay and then we'll create a label the glass of column large two columns and control labor and the name of the label will be name okay and then do with a class of column large for and then you create a input of type text name will be name and plus we'll be form control and placeholder envisioning of the knowledge see or display message displaying me the next box for entering the name of the candidate you know let's just copy this same piece of code and just repeat it for our for the gender now let's just change it to gender okay instead of this text box you have to create select plus gender okay so I'm using okay radio buttons right or this will just remove this and then input type radio and their name gender and then value as male yeah male as well don't just copy put a couple of times it's a couple of times and then maybe one gender should be female and the last will be others again here it should be females others okay I'll see Richard and now let's refresh okay which display in gender as well yeah now we need to create the course so I will do the same thing I'll just copy and I will put it here and then we'll change it to course and instead of these radio buttons I will create a select with a loss of course then options select okay and then I will just copy this and put it here there it should be B and value will be B I'll just copy and paste it a couple of times and then second we'll do be calm that will be PSC and here the same thing be calm be AC okay and then next we'll just copy this and just used it here and now I want to create from for that I will create an input type of text and name will be from gate ID should be from here so the same ID we have to pass here okay so here you can see for this first date because I had said I've said the ideas from and the same from idea how do we use here okay and then next I will just copy the same thing we put it here and then it should be - yeah it should be - to date we have then just copy and then we need to create a submit button just copy here and paste it we don't want this to [Music] let's remove it and then input' type submit' and then name should we submit the class give it BTN retail primary ok here also I should add class as form control mr. poppy and then put it here okay and here as well class form control okay now save it and now let's refresh okay it's displaying course from it to here so this course is not displaying properly to change here of course okay select Tomas but it should be named and I will display properly okay I'll click on this you can see it is displaying calendar is displaying whenever I click on both of this text boxes okay so these two text boxes are our date picker okay so I'll be able to get this collect calendar as soon as when I click on this text boxes because I have used this jQuery dot you added gsm jQuery you are of CSS okay sir and I have given the ID for these text boxes from and two and these two from and two IDs have used here inside my JavaScript okay so with this I'm calling the date picker function which is defined inside these inside this jQuery UI dot J's fine okay so now now the thing which is the left case made to start creating our database okay so here you can see I'll be using the same database which I have used for this already build application you know so I hope you know how to create a database in phpMyAdmin here you can see how created a database with a name called filter inside that filter I have created a table with a name called for a course okay if I click on browse and you can see I have entered these six records manually okay so let's go to structure okay so the first field of ID will be of primary key okay have said this ideas and primary key and have created an another NN and the first field is auto increment it as well okay so you need to set two properties primary key and auto increment it here you can see this is and this primary keys symbolist is having some different color greyish colour official that means this ID and this you here you can see the key is also indicating here that means this ID field is set as primary key in auto increment it okay and this is of integer type and then I have created a field and iam use of the wire care and then email work and gender where can course were kept from date will be of the type date and then tool it will be of the type date okay so I have created a table of seven fields and I have inserted few records because for inserting unit to go to insert and then you need to enter the details of all this fields except idea because I have set at a set as an auto incremented so you don't have to enter any value for this ID while entering while inserting the data okay so other than ID you have to enter the details for all these fields okay now my database is set so now let's create or DV dot PHP file so for that let us come to config and then click on active on this one folder and then save it as DV dot PHP okay and inside this DV dot PHP file I will be creating one database I will be right in my database configuration idiots like my server name and then user may password database this all these videos I will be writing here [Music] so someone we will be discerned not not one and then user is root and password I haven't said any password for my database or just leave it as blank and then DB name okay I have created a database and to that univers I have given an MS filter so we just use that filter okay so now let's create and connection object and then MySQL I connect and then when you to pause this or somebody else server and then user and then password and then DB name okay and then we to check using if-else condition okay if our connection didn't get stablished with the database if not connection then I will be displaying an error message to the user saying connection field okay and then masculine connect error okay else I will just no message this connection established we are now save it okay now we located our review dot PHP file inside this file we have said or it abyss confirmation details and now we have to include we need to include this file this day my dear this DB dot PHP file inside our inside or index dot PHP file okay so now save it first okay and now let us come here project okay so now below this form I want to display a table exactly the same way I have displayed here before that I have to come here okay below this first row I need to create in one repeat one more row do with a class of a row okay and then a little bitter devil will be that loss of table table strip yeah and then table overall these classes are from both services and then talk later Abel head gooble hurt and the way to create a role to hang them i D DeeDee yeah it should be ID okay I want called coffee fields like name email gender course [Music] name gender email course mean email general cost from and to okay and then the sloppy and we're here and then too okay so now let's refresh - I was displaying this table okay so a mistake is your booty edge because that's the header vegetable th copy I was pretty clear Sierra you know should be th okay I'll save it and now let's refresh oh yeah now it's displaying that table properly we are now we need to include by maybe dot PHP file before that to create feeble body the inside this PHP include conflict / DV dot PHP like a hand here then we need to check if is set if is set dollar underscore lost submit okay if our post request is set because oh we need to give the same name what I have given for name okay so yeah name is submit so I should use that name as submit here inside here inside this is set okay so here I am saying if the post request is set then I should get the details like name nor understood post and then name coffee the Fosters name and then gender and just copy material and then email in the course from and then to prop a fruitier okay and now I need to check for the input validation okay if you check for the emptiness dollar name is not not equal to empty or you can just copy this okay name and gender email horse from date from right here it also should be from date and then we are should to date okay so here these fields which I have mentioned inside this post array name gender email course from read and to read these fields should exactly same with the fields whatever I have given it here okay here you can see name his name and then gender here name will be gender and then course name will be course and then from date from date okay and then here for to the name is to read okay so exactly the same name I have to given here okay and these names should exactly also match with the database fields okay so now let's come to our table okay so and these fields are also exactly same with these fields again okay next you can able to write the query very Oh select star from other cars yeah name is equals to name our our gender it goes to Zenda email is equals to email [Music] course is equals to of course then from date is equal to dollar wrong date and then may to use ad to lead the sequester dollar to date okay so now this these are the database fields name gender email course okay and whatever I have assigned values this dollar name dollar gender and this dollar email dollar course all these details user will be going to enter or select in this form and those values will get assigned to these database fields and then next theta goes to mask you by query then - I'll pause the connection which is coming from PI DP dot PHP file okay and then ready Oh and I have yeah and then I will check if my table contains some recourse or not if as yeah yeah if my SQL I num rows greater than 0 and to this I will pass the data you can 0 and then while Dola row last July which associative array do this I'll pass the data okay and then I will get the records and all ID costume dollar a row and then ID okay I am getting the data from the PMO and I'm storing the data inside this area was IT name gender email and then from date to date this copy right here okay now save it and we need to lose it ESP okay like to create a row and side this way to create a TD and then PSP equal dollar ID copy the name gender emails from date and that turret can save it and then else else if our table doesn't contain any recourse at that time I will create one more row and in that I will display a message records not found yeah save it and now refresh displaying me an error none expected end of file and 144 okay here this if okay open and close standard and this year if okay oh s--- yes be you know this one is if okay while I wanna close it more save it okay now displaying Nik collection stablished okay so now let's remove it okay this one is a reader base file okay and okay it's not fetching the Wreckers connection establish you can dollars equal this query exit okay so now it will not display okay here but alleged we let it be like this and our lives refresh and now I J okay now if I click on submit now it should display me over here is displaying me undefined index gender and email not one and one not two not to come here gender and email okay name is Jim de okay we don't have email field undefined index email on one not two okay so here I am not accepting email so for that I should remove this email from here and from here as well and you're as well okay save it personally fresh okay nice not displaying me any error Phyllis remove it - I'll save it and refresh okay now it's determining me the data of all those the records who who's having the gender s meal so now let's the commercial not displaying in proper format so let's see do you are just cut it out over here now let's refresh okay now it's displaying me okay name gender email course from and - okay to date okay others check female okay explain all the details of female email gender [Music] course founded and to read okay here our team name emails Xander corsican alerts refresh - are displaying properly we know if I want to get the details of become and now display me undefined index gender okay so here who is there - check true save it okay become students okay let's display the regions of become and if I want to get ba now it's displaying me BA and now if I want to get vsi's friends displaying me BSC as well okay now let's say if I want to get Anita's details is displaying me honey those details and then Suraj teachers okay if I want only male candidates it's displaying email if I want only female vendors is blaming me female candidates and now if I want records from January to me okay let's see okay just not displaying because here you'll see our treat format is not correct okay so here so whenever I select an adage is displaying that date in the format of month date and year here as well month Dayton here but inside the database is displaying the date in the format of year month and date okay year month and date okay so we need to change to this format so for that we need to come here here we need to change it okay and then to date we first found it it will change from date did goes to steer to time okay and then to date and then to date was did year month and did okay here we had to change it to the same format whatever we are having inside our database so - she was this update next we need to do the same thing for to date as well here it should be from date okay to date should be from that will to date okay now we need to pass this update here to date here ch now let's come back here okay mother select this first month and then me okay still you start displaying and of course get on there sick yes from here should be update read should to date okay and then okay here should be greater than and equal to and here it should be less than okay I want to I want to get the records from these two date ranges okay and now let's refresh before 1st January to 31st May allows see still not displaying ok Safin recovered meum agender course and from date is f date and tool duties okay here should be through date set of effort okay so now let's refresh and others make it to first January and now let's see okay now it's returning me all the records within that range okay now if I want to select some other date from second month to May 31st and I was displaying me only for the cards that comes under that range you know if I want to get the record of second to third month now we don't have any regard in that range you know let's select second to April okay let's take from second to fourth month we have to every local artists displaying this they can record that comes under the trails okay so now if I want to who get Anita's record now it's displaying me and it does record and now if I want to get only male candidates it will return me the radius of only male candidates of course your stones displaying properly dollars the name gender email and one more field which is course refresh ok now displaying me courses and now if I want to filter based on courses say here's this pin only become and life I want only be candidates displaying in v8 and if I want BSC displaying be a CFL ok so this is how we can filter the records ok now when i refresh and this time it's not displaying me anything ok so at this time it should display me all the record so for that what i should do is i will come here in else condition ok here I will put not okay and then I will take it we'll cut it and I will put it here okay and and select whatever is there inside this if condition copy and I'll just put it here okay and I will just change this query select star from reports that song whenever I enter into my project okay so now if I want to see only becomes words I can see only become if I want to see the instruments I can get only if I want to only mail their only male headers if I want female when I will get female candidates if I want to get some specific and a card then I will get only that record okay so things how we can apply different filters on PHP using PHP okay so I hope you like this video I hope you are some useful and valuable information all over this video if you like this video click on like button share it with your friends and don't forget to subscribe to our channel well see you guys in my next video and thanks for watching
Info
Channel: How to Make Tut's
Views: 97,649
Rating: undefined out of 5
Keywords: How to Filter Database Records using Textbox - Radiobuttons - Dropdown and Datepicker using PHP, how to search different records using php, how to filter records using textfield in php, how to search records using redio buttons in php, how to filter records using dropdown in php, how to filter records using datepicker in php, how to fetch records from database using php, how to filter specific records from database using php, how to establish database connection using php
Id: Q1g1QXqPsSM
Channel Id: undefined
Length: 54min 44sec (3284 seconds)
Published: Fri May 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.