I am trying to figure out the best way to include the values in a multiline textarea webform into a sql select statement that is processed when the submit button is pressed. The values in the textarea will be single servernames, one per line. When combined it will need to be put in a format like this (‘servername1’, ‘servername2’, ‘servername3’) and so forth. The sql statement would be like this - select * from table where servername in (combined values from textarea);
Below is what I currently am using that works for a single value in the textarea box. Any help on how to accomplish this would be very much appreciated.
[php]
<?php if(!isset($_POST)) die("Bad behavior"); echo "Results..."; $strServerName = $_POST['ServerName']; mysql_connect("localhost", "user", "") or die (mysql_error()); mysql_select_db("ServerList") or die(mysql_error()); $strSQL = "Select * from table where servername = '" . $strServerName . "'"; $results = mysql_query($strSQL) or die("
$strServerName
".mysql_error()); echo "
" . $arr['hostid'] . " | "; echo "" . $arr['servername'] . " | "; echo "" . $arr['console'] . " | "; echo "