I need to know how to do the following using php coding please
1.take inserted text from a textarea
2.split the content per line
3.Insert each line into the database as its own row with own id number
Can anyone show me how to do this please?
THis is what I have tried so Far:
Below is my form page [U]display_form.php
[code=html]
<form method=”post” action=”display_db.php”>
Member ID:
<input name=”mid” type=”text” value=””><br/><br/>
Enter Keywords:
<input name=”keywords” type=”text” value=””><br/><br/>
Enter Your Links :
<textarea name=”links” rows=”3″ cols=”20″></textarea><br/><br/>
<input type=”submit” id=”button” value=” Submit “/>
</form>
And below is my [U]display_db.php
[code=php]
<?php
$con=mysqli_connect(“localhost”,”root”,””,”test”);
// Check connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
if(isset($_POST[“data”]))
{
$line_data = explode(“n”, $_POST[“keywords”]);
foreach($line_data as $key => $value)
{
$sql = “INSERT INTO table (display) VALUE(‘{$value}’)”;
mysql_query($sql);
}
}
if (!mysqli_query($con,$sql))
{
die(‘Error: ‘ . mysqli_error($con));
}
echo “1 record added”;
mysqli_close($con);
?>
Ant kind of help is appreciated.