Hi,
my code works for one line input but Im trying to get multiple lines in a Textarea post and that does not work. for example if I search " robin " it searches for robin and it works but if I search " robin [newline] rico [newline] charly " it does not work
This is the code so far:
[php]
<?php $db = new mysqli('localhost', 'root', 'root', 'root'); session_start(); if(isset($_POST['submit'])) { $textarea = trim($_POST['search']); $search = explode("\n", $textarea); $search = array_filter($search, 'trim'); // remove any extra \r characters left behind $_SESSION['firstname']= $textarea; if(($_SESSION['firstname'])!="") { header("location:index.php"); }else{ echo ""; } } if(($_SESSION['firstname']!="")) { foreach($search as $data){ $data = $_SESSION['firstname']; $view = $db->query("SELECT * FROM contacts WHERE firstname REGEXP '$data'"); $check = mysqli_num_rows($view); } if($check!="") { while($output = mysqli_fetch_object($view)) { ?><?php echo $output->firstname; ?>
<?php echo $output->lastname; ?>
Error: Add new data enter and check the correct keyword
<?php } } ?> [/php]
I also tried using " $search = explode(’\n’, $_POST[‘search’]); " but somehow could not get it to work or used it wrong. Could any one tell me what am i doing wrong or missing?
Thanks for any help