I am a newbie and have been struggling with passing the value of my html form in a static dropdown to a php query page that looks up the type of business in my database I am looking for.
The error I am getting is: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/myservic/public_html/results.php on line 12 which is :
WHERE biztype = "'.$_POST['biztype'].'"'";
If there are any ideas, I would GREATLY appreciate it. Thanks!!!!
MY HTML FORM
<form action="results.php" method="post"><div align="right">
<div align="center"><br>
<select name="biztype">
<option selected>-select type--</option>
<option value="cleaning">cleaning</option>
<option value="electrical">electrical</option>
<option value="plumbing">plumbing</option>
<option value="heating_cooling">heating/cooling</option>
<option value="other">other</option>
</select>
<br>
<br>
<input name="Submit" type="Submit" >
</div>
</form>
-----
[MY PHP PAGE]
<?php
$db = mysql_connect("localhost","mylogin","password") or die("Problem connecting");
mysql_select_db("mydb") or die("Problem selecting database");
$sql = "SELECT * FROM contractor
WHERE biztype = "'.$_POST['biztype'].'"'";
$result = mysql_query($sql) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
echo "<TABLE BORDER=\"1\">\n";
echo "<TR bgcolor=\"lightblue\"><TD>Company</TD><TD>Phone</TD><TD>Rating</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result);
if($i % 2) {
echo "<TR bgcolor=\"yellow\">\n";
} else {
echo "<TR bgcolor=\"white\">\n";
}
echo "<TD>".$row['compname']."</TD><TD>".$row['phone']."</TD><TD>".$row['rating']."</TD>\n";
echo "</TR>\n";
}
echo "</TABLE>\n";
?>
[code]