Edited Question:
Thank You for your answers. Sorry for that i am not really looking as per your answers. I want multiple insertion from textarea box while form submission.
i have this result. i want to insert multiple data (both column and rows) into mysql table using (textarea box) (on form submission)
when we copy above data to textarea box its look like below
following source link already done with single column values.. But i want to insert two column values same time in mysql.
https://www.webslesson.info/2019/06/how-to-insert-multiple-data-into-mysql-in-php-using-textarea-field.html
Any one help me for code
i found two discussion page here below same like my question
How to insert multiple row from textarea to multiple column?
How to insert multiple value and Multiple rows from textarea to MySQL using PHP?
---- but from above no answer posted properly...
For eg:
I want to insert following two columns (state,distance(miles) in mysql using textarea box.
Firstly, you have to use <form></form> tags around the table.
Then to get values of each columns in a row, you can use some <input> tags inside the <td> tags. The reason why doing this is because <td> tags don't have a name attribute and thus cannot use php $_GET or $_POST variables
Once you have the name attribute, use $_POST or $_GET to capture and transfer to database
You can check this link. This will give you some insight
Link here
Related
I have a simple HTML form with three fields name,school and city. Also within the form, I have a button which I am using to insert a sub form with values neighbourhood and population. The crud mechanism is using jquery append.
In my database, I am saving the main form data in one table and the sub form data in another table.
My question is, during the creation of data in the main form, if I insert the data of the main form into one table and get the last inserted Id and use the id as a reference when inserting data into the second table, will this approach always work in both mysql and ms SQL?
If not is there a better approach I can adopt?
It will work, as long as your dynamically created input has the proper name attribute..
For example: name="txt_neighbourhood"
I want to create a dynamic number display of texbox, there will be a a textbox and a submit button, then the numeric value of my first textbox shall display also the number of textbox. Which will allow me to input my records in my database. I am using MySQL for my database and how would I insert the records to my table if the first set records of my textbox is not the same as the second (example I input 3 on my first textbox then three textbox shall appear and a submit button, on my second set of records I decided to have 6 on the first textbox then six textbox shall appear in the page) my question again how am I going to do this?
If ever I use array in fetching records and indexing the value of my dynamic textbox, what type of array shall I use to this? How will I going to name the value of my textbox dynamically? and lastly the I wanted the restrictions also that will set the maximum number of textbox.
Ok. Multiple textboxes, let's call them columns. The first record the user enters in each row is the number of columns they require. The submit button would just call a javascript function to create the required amount of columns for that row on the page. This would have the restriction as to how many can be created and the PHP would also ignore extras if the user works out how to cheat it.
Jumping to your last question (because the second question needs this info). You have decided what the maximum number of columns is so the easiest way if that number isn't large would just be to create a table that can satisfy that many columns. Some fields would be NULL on some rows.
It doesn't matter that the number of columns is different when you want to insert because, for each row, you expect up to a certain amount and only deal with the values you are given, those missing are NULL. When you come to output them you only output those that aren't NULL.
The bit about using an array in fetching records and indexing doesn't make sense to me sorry, but I suspect you're fishing for what php database class to use get the data back from the database? I think the trend is mysqli. Personally I use a bespoke one.
I've been trying to insert check boxes next to values retrieved from a MySQL table and the output is in the form of a HTML table.
The output is on the same page as the query form which will retrieve the values in the form of the table above. Now, I wish to insert check boxes beside each row/entry received from the database and use it to update the notification_sent column in the database, but so far I've hit a roadblock with this.
Just add one more td with the checkbox code:
<td><input type="checkbox" name="notification_sent[]"/></td>
i want to add rows using loop and then want user to fill the rows then i want these rows' data (tds contain textboxes and selection lists)to be saved into database? i need to know how is it possible? jquery and php will be preferred.
DatA not datE.
run this command in loop. rows automatically added in your table
mysql_query("INSERT INTO table_name(feild1, feild2) VALUES ('value1', 'value2')");
the easiest way to do this is to create a php file which will take arguments from jquery and execute it.
while assigning each element of form a unique id and counting total rows will give us a chance to use loop and we can send each row elements' data using loop. php file will get the arguments and execute it .the ajax request will be send count-row times.
I have two text fields and a button, on the click i need to save them into MySQL Tables.
The top text box field data in table 1 and data in text box in table two...
How to perform it.
Well, i guess your form execute some server-side PHP.
Then in this PHP juste use mysql_query() 2 times, with your 2 insert.
As MySQL does not seem to support multiple inserts in otwo tables you can do it with a transaction with two inserts or with a stored procedure.