I'm trying to take lines of text in a textarea of a form, and turn them into a query from a database. But for some reason, the variables are not showing up in the query I've constructed.
Here's what I have so far:
<html>
<body>
<?php
$table_variable = $_POST['chosen_table'];
$chosen_insert = $_POST['chosen_insert'];
$textfield = $_POST['textarea'];
echo "texted: ".$textfield."<br/>";
if(isset($_POST['textarea'])) {
$query = "SELECT DISTINCT item_id FROM table WHERE ";
$text = explode("\n", $_POST['textarea']);
foreach ($text as $line) {
$insertLine = explode("\t", $line);
$insertLine = explode(",", $line);
for($i = 0 ; $i <= 2 ; $i++){
$insertLine[$i] = mysql_real_escape_string(trim($insertLine[$i]));
$query .= "taxonomic_genus = '{$insertLine[0]}' AND scientific_name = '{$insertLine[1]}' AND infraspecific_epithet = '{$insertLine[1]}' OR";
}
}
$query = substr($query, 0, -2);
$result = mysql_query($query);
echo $query;
}
?>
<form name="myform" method="POST">
<textarea name="textarea" id="textarea" style="height:300px;width:300px;"></textarea><br/>
<input type="hidden" name="chosen_table" value="table">
<input type="hidden" name="chosen_insert" value="412">
<input type="submit">
</form>
</body>
</html>