I have a site list which I want to save it to a mysql DB. I get these sites as a list of 30-60 sites so I don't want to do it line by line. So i want to paste this list into a textarea box and then create a record in a table for each of these sites. can someone tell me how to do this with PHP ?
This would be the bare minimum <?php require('includes/config.php'); // method to connet to the database $links_list = $_POST['links']; $arr = explode("\n", $links_list); foreach($arr as $link){ mysql_query("INSERT INTO `table` VALUES('$link')") or die(mysql_error()); } ?> <p>Your Links<br /> <form action="#" method="post"> <textarea name="links" rows="4" cols="20"></textarea> <p><input type="submit" value="GO"> </FORM> </p> PHP: You would probable want to make some checks to see if a link already exist in the database, so maybe adding an id to table would help with that.
When pasting the sites in the textarea box use a pattern for example; site1.com;site2.com;site3.com;site4.com;site5.com In this example we have separated the sites using the ; When you submit the form to the server use the string function explode () which will return an array of strings from a string based on the separator. This is the prototype: array explode ( string $delimiter , string $string [, int $limit ] ); Then save each array variable in the mysql database. Do you have the basic knowledge in PHP & Mysql/