Multiple edit of a database table in one form - php

ok heres my problem.
I have a database table that i want to edit multiple rows by using one form.
I am looking for a way to be able to display a form in which i will be able to edit the rows and save the entries in a grid view kind of way.
Can this be done by dynamically letting the user choose which fields he wants to edit or provide an excel sheet kind of interface where changes are made and saved to this already existing database table.

Using PHP, if you name the form fields as nameoffield[] they will arrive in the request back to the server as an array. Just make sure empty fields have some place holder when they get sent back to the server and just parse through them one by one performing updates/inserts as necessary.

Related

PHP Loading MySQL Columns For a UniqieID Then Updating Columns

Sorry very new to PHP and MySQL. I'm pretty close to having what I need. I created a database that hold values as shown here:
I was able to find some things online to create a form and initially get the data into the database
What I would like to do is have another page to load values for a specific customer by searching for their uniqueid. So have a input box where you input the uniqueid then the current values for that customer get loaded into a form just like the "Customer Creation Form". Then be able to update the loaded values in the the form and save it back. The enddate is probably the field that would be updated the most.
You could use Ajax requests and PHP to update the form live (or update once the user has entered the UniqueId)
https://www.w3schools.com/php/php_ajax_php.asp
To return multiple values grabbed from the database, use php to create an array return it as a json file.
https://www.w3schools.com/js/js_json_intro.asp
https://www.w3schools.com/js/js_json_arrays.asp
https://www.w3schools.com/js/js_json_php.asp

How to add only one data in database table in laravel

I am creating a site and i am making a general option page for the site that include the site name, logo, social links so that i can manage them dynamically from one place without changing the links and text in all pages where i called them.
What I want is that the table i created in database, i want to have only one row in it. If someone try to add other row of data it should not be added because i have to call only one data for the site.
I hope the query is clear to all.
Thanks for your support. Help me if u can. please :)
By,
if someone try to add other row of data it should not be added
what do you mean? Are you trying to avoid unauthorized access? If yes, then you need to implement roles https://laracasts.com/discuss/channels/general-discussion/roles-and-permissions-in-laravel-5
To manage your site information, I'm sure you set a form that will be used to update the site info. And from the look of things you will only be updating that row when you hit save or update button. I don't think you will be doing full CRUD here just updating so there'll be no chance of inserting a new row of data in the db.
So three things:
you want to create a migration, seed the table with the site details accordingly. run the migration
you want to make sure the user trying to access this route is authorized to do so
you want to pre populate the site info in the form fields when the edit site info page loads and you want to save the form when the authorized user changes any of the site info
This way, there'll be no question of stopping further insertions into the db.

Move form entries between Wordpress Gravity Forms

I have a tournament with multiple divisions and multiple forms for which I use gravity forms.
There are times when someone requests to be changed to a different division. However, I am unable to move the competitor from one division to another in gravity forms, as the divisions are each using a different form ID (and they have still not developed a method for helping with this).
How would I go about moving a SINGLE ENTRY from one gravity form to another forms entry list please.
We have many teams at the tournament, so mass export and import is not what i am looking to achieve. Its about being able to move a single entry from one list of entries in one form to another forms list of entries?
ANY help would be greatly appreciated. Even a simple "use this method" in general terms will help me greatly. Would I use some form of JQuery fiddle, a php script, an sql script or what please as Import Entries is not available currently in GF
Regards
You can not do that, but instead maybe you shold design your form to include all types of submissions logic. I mean you can put a drop-down field at the beginning of your form. Then you can use https://gravityview.co/ to edit your single entry field.
I have a workaround for this which i am using in one of my current projects for http://projects.dzign-r.com.au and that is,
1) export both of the the forms (i.e the one from which you need the field to move and the other to which you need this field to be moved to) and it exports these as json files
2) search for the field ID that you need to be moved to another form, cut its json code from the json file and paste it in the other form's json file where you need it to be moved to
3) then import the form back. and test it to make sure it works as you want it, (as a caution you may change the field ID after you paste it in new form to be something which is not used in this form already).
4) once u see everything is fine u may just delete the old form?

How do I store form data temporarily if the form has to be refreshed and re-populated with that data?

I'm working on a recipe input form. The current version of the form is very basic....takes the data entered and inserts it into a recipe table.
I want to change this form so that the ingredients are no longer a simple text entry....rather i want it to be selected from a list of ingredients.
Here's what I've done so far...
- created a "recipe" table which has all the recipe data
- created an "ingredients" table which will be the list of ingredients to select from
- created a "recipeingredients" table which will be the list of ingredients selected for the recipe. this is just a id table...recipe_id and ingredient_id.
Here's what I need some direction on...
- When the user is in the addrecipe page, they would start entering in some information. When they get to the add ingredients portion they will have to click some sort of link that will open a new page to select ingredients. When they click that link, I would like to save all the form data they have already entered so this data can be repopulated into the form when they are done selecting ingredients.
How should this data be stored for temporary use?
SESSION variables?
DB entry without commit?
POST the variables back and forth between pages?
Please let me know if I can provide more information to be clear...
Thanks!
I'd use SESSION variables. That's the cleanest way in my opinion. A DB entry without commit looks a bit like a dirty hack to me. By the way, writing to a file is much faster. Using POST and input type hidden form fields could also be acceptable but keep in mind that the data is included in the html source code in clear text. And for bigger data it can make your source code a mess. You'd better store them in a temporary file. So, if you're using sessions anyway and your data isn't too big go for SESSION variables. Moreover if the data is of any confidential nature using SESSION variables or protected files on the server is obligatory.

JQuery Dynamic Table

I have a form with a dynamic table on it plus other fields. You start with one row and can add more at execution time. It's used to track incoming and outgoing items on a store. You add each item and then fill some common fields (time, date, person who received them, etc).
General fields are stored in a table, detail ones in another table which is related with ID field of the first table. I send first the general fields with jquery ajax, save them on db and then use the ID for saving the details with other ajax call. When finished saving, I clean the inputs with jquery and if I add another registry the previous items are also added unless I reload the whole page. I use mysql+php+jquery 1.7.1
How do I clean the Array? or what is the best method for doing this?
Tell me if you need some code, thanks in advance...

Categories