How to bulk insert in PHP form textarea input? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to create a form that should have a textarea as bulk input, then every row of that textarea can be store able as separate value in table via PHP.
What should I do?

The key piece of code is:
$values = explode("\n", $_POST['textarea_name']);
Don't forget to sanitize your inserts :)

I use this code
$values = explode("\n", $_POST['textarea_name']);
mysqli_query($con,"INSERT INTO `table` (`col`) VALUES ($values)");
data should be string.
How I can convert it to string? I want to make each row to a record! make my code compelet!

Related

mysql update data entry in column without removing previous data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
What I'm trying to achieve is whenever this column is updated, it shouldn't remove the previous data that has been filled, instead, it should just enter data in the next line with the previous data too.
For example
Author 1
Author 2
This is my code
$booktb = $db->update("books", "author" => $author);
I've looked into this question but it didn't work for me
Update data in mysql column field without removing previous value
pseudo code
$b = $db->select("books","author" => "kafka");
$b["title"] = "another book"
$db->insert("books",$b);

Use MySQL to generate semi random string on insert [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I would like to know if its possible to have mysql generate a semi random string when a new entry is inserted into a table.
so if my table has a column called Code , when a new record is inserted can mysql generate a random string of numbers and add that onto the end of what was inserted into code.
eg if MCQ is inserted into code , mysql will do its thing and add 123 onto it giving MCQ123
It should be possible using TRIGGER. But why not inserting the random string with the insert data?

PHP language arrays and text [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a text box and I wrote some text in it.
the question is, how to put the written text inside an array, and then use the explode function to separate each word ?
first get the value like this (I assume that you have a form and you send it by POST):
$name_of_array = $_POST['name_of_your_form_field'];
$separeted_vars = explode(' ', $name_of_array);
I hope this help you!
p.d: the $name_of_array isn't necessary that be array...
Something like this:
<?php
$words = explode(' ', $_POST['textbox_contents']);
?>
"this is some text to be separated" // this is written in a text box with a button called separate
the array is gonna be used in the explode function
the expected result is
this
is
some
text
to
be
separated

Breakdown MYSQL Results [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am currently getting data from a database using PHP and echoing the data out using:
$data[0]
This displays a full list of account numbers, I am wanting to put a href around this so that when I click on each one of the account numbers it runs another MYSQL query which breaks down to more information based on the account number that has been clicked.
How can this be done?
The href could point to another script which evaluates the $_GET parameters and builds a query from it, like in
12345
and
<?php // details.php
...
mysql_query( "select * from mydata where id=$_GET['id']" );
This is just a pointer, and the example is prone to SQL injection etc.

Calling a field from database in MySQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
return(array($clientName,$salesPer,$prospectVal,$projID));
The projectID is dynamically added in database for each entry, now how can i return the ID. As i have not set any variable in PHP to map the database field.
Can anyone guide me on this.
If you're asking how to get back the ProjectID after it has been inserted into the database and automatically assigned, I suggest using something like the following:
$projID = mysql_insert_id();
immediately after running the insert statement.

Categories