Query Select where = form input
Posted: Sat Aug 02, 2008 6:34 pm
Hi all,
Frustration setting in
Can someone please tell me what is wrong with the above code.
How do I get the forms input to be what the search equals?
Cheers
Frustration setting in
Code: Select all
<form>
<select name="find" value="<?php if (isset($_POST['find'])) echo $_POST['find']; ?>" >
<label>bank</label>
<option value ="Commonwealth Bank">Commonwealth Bank</option>
<option value ="Westpac">WestPac</option>
<option value ="City Bank">City Bank</option>
<option value ="St George">St George</option>
<option value ="Bendigo Bank">Bendigo Bank</option>
</select>
<input type="submit" name="submit" value="Post Comment" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
<?php
require_once ('mysql_connect.php'); // Connect to the db.
$find = $_POST['find'];
// Make the query.
$query = "SELECT(name) AS name, (comment) AS com, (date_reg) AS date,(sub_by) AS user FROM banks WHERE name = '$find'";
$result = @mysql_query ($query); // Run the query.
$num = mysql_num_rows($result);How do I get the forms input to be what the search equals?
Cheers