I'm making a simple inventory system using PHP and MySQL.
Is it possible to add multiple items after clicking a button and save them into a database? Like adding 5 items with different stock no.
I can only add one item at a time.
You'll need to add additional input fields in your form for each item you want to add. Each one will need a unique name (e.g. item_0, item_2, etc...). In your form handler, it should check which ones are not empty, and insert them.
If you need help implementing, post the code that you currently have.
Related
I don't need any code, I just need the right way to do it.
What I am doing?
Here is the thing. I am making a software for a pharmacy (Drug Store). I have created a tab for shortlist for the drug. See the picture.
enter image description here
What problem I am facing?
In the last column, I have a form field to input drug or add stock. But you can see there are many form fields for so many rows. When I click to "Confirm" button, it's not gonna work cause the table has been generated using loop. So, for all the fields there are same name.
How can I take the value of input field right above the submit button. I mean when I click confirm button it will take same row's input field not others.
How can I do it? No code needed. I am using php codeigniter framework.
Thanks
create one variable like '$i' and increase it and append it on last of input name.as well as give id to submit button and append id with $i.
for eg. name_1,name_2,submit_2,submit_2
when you submit just get the id of submit button. Then get the number from id eg.2,3.take input from the same input variable id. You can do it using ajax. So it will be done without refresh page.
How can I add certain values to a form with Drag n Drop?
I would like to create a drag n drop list of groups that a user can choose to send information to. A user can drag and drop the group name to a certain area. After this operation, the form must know what group_id was added to the form (via hidden field for example).
How can I achieve this in an easy way? I would like to use jQuery to do this. FYI, I am using CodeIgniter and mySQL to process my forms.
Thanks in advance.
I have two tables, incldues and TIncludes which are used for storing three columns of data; An ID, macro_num, macro
The includes(table1) has all of the items possible to list, these are shown by macro_num in a listbox on the form (select1). The user can add the wanted items to the second box, select2. The listboxes populate and move the data to eachother, add/remove buttons using javascript.
I can't seem to get the data from select2 to insert into my database. Not sure what I setup incorrectly or overlooked.
Are there any working examples of such a thing? I have only seen where one item is inserted and that is fine, but I have some reports which need 40 items.
Thanks in advance for reading this. I hope there may be a quick solution as I have not dealt with this problem before.. my first large form item requirement.
The PHP form handler is only going to know about the options that are selected in your list. You'll need to do more than just add the items to a select element to get them to your code. You can add them to hidden elements, or you might be able to force a select-all through javascript as the form is submitted.
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...
I have a form-1 which has 4 fields. when the user inputs data in these and hits submit, he is taken to form 2 for further selection of more items from multiple selection box. after selections are complete, he is prompted to update and on updating, all the data has to go to a third form for processing.
currently i am passing the single fields data from second form to third form by <input type="hidden" name="abc" value="<?php echo $x[0] ?>">
I am getting stuck as to how to retreive all multiple selected items from the array, perform a calculation on them and then post to mysql and then update the user with posted information.
or is there a better way of doing this, pl. guide me. my fields are:-
first page
customer id - single selection field
date - input
segment selection - single selection field
second page
items inputs - itemid, quantity,price (these are in one row and user will dynamically add or delete rows based on requirements. i have done this through Javascript)
now after all this, i want to gather all details of customer, segment, items(id,quantities,prices) and then post them to mysql.
If you want to use separate pages you can use either hidden inputs fields or sessions to pass along their selections. With sessions, you'd just store the array of data in $_SESSION and use session_start() on each page to get the session from the previous page. With hidden inputs, you can store them just like you would with session, and when they click POST you will rewrite them into the form. Are you stuck on specific aspect of doing this?
On the final page use either the session or the hidden fields (depending on your chosen method) + the final POST, to query MySQL.
Note: As Zirak mentioned in the comments, you could also do this using a single page. You'd use one of the same methods described above, except it would post to itself rather than to another page. This might be a faster/better way to code the page... If you opt for the single page method just ensure that you make it possible to go back, both through their browsers back button and a link you provide.