burntheblobs Posted October 30, 2008 Share Posted October 30, 2008 I have a search form that reads both an input field and a checkbox selection. It seems that when I check the appropriate checkbox and enter in an appropriate search query, nothing is echoed. However, if I check the correct checkbox again, then hit submit again, it will echo the correct results, just like it is suppose to. Here is the form code in my html section: <form method="post" action="search.php"> <input type="text" size="45" maxlength="45" name="date_Name" style="vertical-align:middle;"> <input type="image" SRC="images/searchbutton.png" ALT="Submit button" style="vertical-align:middle;"><br> <input type="radio" name="checkBox" value="name">Name <input type="radio" name="checkBox" value="school">School </form> And here is the procession section: if ($_POST[checkBox] == "name") { $query = "SELECT dateName FROM date WHERE dateName LIKE '%$_POST[date_Name]%' ORDER BY dateName"; $result = mysqli_query($cxn,$query) or die ("Couldn't execute query."); showInfo($result); } function showInfo($result) { while ($row = mysqli_fetch_assoc($result)) { extract($row); echo "<a href='viewdate.php?date=$dateName'>$dateName</a><br><br>"; } } Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted October 30, 2008 Share Posted October 30, 2008 Could it be that you only specified the showInfo function after it is called? Quote Link to comment Share on other sites More sharing options...
burntheblobs Posted October 30, 2008 Author Share Posted October 30, 2008 That shouldn't effect things. And I use very similar functions in other scripts with no problems whatsoever. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 30, 2008 Share Posted October 30, 2008 odd i dont really see anything in the code that would cuase that but on a side note why is your submit button in the middle of your form? also a radio input named checkbox would mess with my head Quote Link to comment Share on other sites More sharing options...
suzzane2020 Posted October 30, 2008 Share Posted October 30, 2008 Place the showinfo function on top. That will solve the problem. Quote Link to comment Share on other sites More sharing options...
burntheblobs Posted October 30, 2008 Author Share Posted October 30, 2008 1. The submit is in the middle so it appears as an input field with the search button lined up, then the checkboxes on a different line. Aesthetics. (don't forgot this is a search form!) 2. Placing the function at the top does not solve the problem. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.