PHP Ajax CRUD Application Finally Made Easy! Download Source Code: http://codingpassiveincome.com/php-ajax-crud-application-part-3 In this tutorial you …
Original source
PHP Ajax CRUD Application Finally Made Easy! Download Source Code: http://codingpassiveincome.com/php-ajax-crud-application-part-3 In this tutorial you …
Original source
26 responses to “PHP Ajax CRUD Application Tutorial – MySQL & Bootstrap & jQuery DataTables [Part 3]”
How can I add custom drop-down search filters to this!? All my attempts ended in making the table go blank when I use the examples on the official page of the plugin!
EDIT: I figured it out! If you create a Drop Down menu in html then just add this line: $('#dropDown').on( 'change', function () { $('.table').DataTable().column(1).search( this.value ).draw(); }); after $('.table').DataTable();
Keep in mind this only works as a filter for one specific row! For multiple rows, you can consider adding the default API codes: https://datatables.net/examples/api/
Now I have 2 more important issues. The table does not update after I add a new entry and if I edit an existing country and rename it to one that already exists it allows me to have duplicates which I would certainly like to avoid! Any help would be greatly welcomed! <3
EDIT 2: For the edit duplicates I solved it like this in Ajax,php:
if ($_POST['key'] == 'updateRow') {
$sql = $conn->query("SELECT id FROM country WHERE countryName = '$name'");
if ($sql->num_rows > 0)
exit("Country With This Name Already Exists!");
else {
$conn->query("UPDATE country SET countryName='$name', shortDesc='$shortDesc', longDesc='$longDesc' WHERE id='$rowID'");
exit('success');
}
}
Now I only need to solve the Page update on adding a new Country!
EDIT 3: I could not find a good solution for the table update. From what I know, I would have to use $('.table').draw(); but so far I have been unsuccessful in my endeavors. I'm using: window.location.reload(); to reload the page as a workaround. I placed it right under $("#manageBtn").attr('value', 'Add').attr('onclick', "manageData('addNew')");
If anyone can find a good solution for this please give me a nice reply ๐
EDIT 4: Sadly, the method used here can not update the table because the data is not parsed through Ajax, therefore we can not use ajax.reload() function. In this method, once the table has been initialized it cannot be re-initialized. The good news is that I found a tutorial that uses this: https://youtu.be/rSRGfXXVFxA – P.S. it has a robot voice but eh, what can you do!?
Senaid You're awesome! The way you proceed , the way you explain stuff never missing out any details or functionality is unmatched and quite helpful for beginners like me. Keep Up the Good work mate! ๐
I'm working on a college project and i'm using your model for the same i was wondering if i could add save as pdf button on clicking view button along side the close button. i know how to add the button as you showed by adding and fading it out on the other menus but how do i link the functions to onclickaction of that button. i'm trying to achieve it by tho but if i could get a bit of help that would be great.
how to add category search also
when i am trying to add new record model title is showing name of country from previous record. How i can make it correct?
Really amazing. But i have a problem? You use pdo and i generally use simple mysql to connect with php. Can you tell me the basic syntax difference so i can change your code to simple mysql and use. I try to find out things but i didnt find it? i dont know whether you will reply or not but if you reply send me a copy to my email "mangla.vishu@gmail.com" thanks in advance
hi, excelent but how we can add an excel export button. thanks
Brother please give you skype pr facebook
When I add the delete function, add new function does not work. How can I solve this ?
Really amazing something i have been for a while now. Thanks man ๐
Excelent Series… Thanks…
Hi Senaid again, it looks like the draw() solution you suggested earlier does not work. Do you have another tip? I am trying to achieve table reload/refresh for both, deleteRow() and manageData() for update and add.
Right now Add New will not refresh the table with the new entry. Also, I figured that $("#cat_"+editRowID.val()).html(name.val()); for Edit option is more of a workaround just for the Country field only.
DeleteRow() needs the refresh too, because it doesnt update the "Showing 1 to 10 of XXX entries". XXX stays the same and doesn't decrease. I think that a complete reload can help all options: add, edit and delete.
Please help!!
What a wonderful work, Senaid! Your pace and continuity are simply amazing! At first I thought it was scripted with cheat sheets (which is ok), but sir, seeing how you pick your choices and build as you go, that is so impressive.
I loved your tutorial and I am using it as a reference for my project. If you don't mind I wanted to ask you for just a guidance, not a ready solution on a plate… What would be your take on reusing this code for managing multiple tables of different size? I would hate to create a duplicate copy for each table, and instead try to reuse its functionality. Do you have any suggestions for me? I just need the approach and general cornerstone ideas. As for the rest I will do my research and find details "how to". Or maybe there is another tutorial that covers how to reuse functions and the recommended "architecture" – what to place where and how to tie everything in together. Something that I could use as inspiration and combine with this tutorial? Thank you sir and much much respect!
i used your code in my project.it's working fine. but it not show search option and pagination.how can i fix this error? can you help me?
no email link download send to me
i really like how you explained things ,, so easy to understand
Hi Senaid, Great tutorials once again! You are such a kind person for sharing your knowledge with us. I wanted to ask if you can create additional data entries that handle images too? It just handles all text data. Thank you ๐
Hi, when I open your code on the web the code keeps adding new IDs:'.$data["id"]. and country names: .$data["countryName"].'. Any help ?
Where is the source code? The link above just brings me to your website.
Hi senaid. I just found a bug recently. I dont know if its only my problem. but whenever i click edit first then I click the add new it retains some info about the edited module. can you help me?
Senaid thanks for the great video. One question, you are deleting row from the Datatable , so it is not sending Ajax query to the MySql , refreshing and showing "real situation". Let me explain, when you delete table row, you don't have any more 10 entries, but 9, and deleting next one will leave us with 8, this issue will be much more visible if you have striped rows, one white, and underneath one gray, so, if you delete 2nd row, you will have 2 white next to each other, and that doesn't look nice. Any idea, update?
download link not working. thumb down ๐
Hi i just want to ask why is my new append row table disappearing whenever i click the desc asc function of datatable? how do i prevent it?
Another good video.
Thumbs up!
Thank you, Senaid!
Nice Tutorial Senaid. I was looking for a cleaner, admin section with adding news or whatever… This is the cleanest i ever saw, so far.. THX!!
thank you so mcuch for help dear sir