edrew04 Posted October 6, 2009 Share Posted October 6, 2009 my search query wont work, i know, that my codes are correct.please help <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <div id="insidebox1"> <form name="form3" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <tr><td><p>physician_ID: <td><input type="text" name="pat5" id="pat5" size="15" maxlength="11" value=""/></p></td></tr> <tr><td><p><input type="submit" name="btn7" id="btn7" value="Search Physician"/></p></td></tr> </form> </div> </table> <?php if (isset($_POST['btn7'])) { echo "<center/><a href='physicians.php'>Check the search results </a></p>"; mysql_query("SELECT * FROM physicians WHERE Physician_ID={$_POST['pat5']}") or die (mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted October 6, 2009 Share Posted October 6, 2009 Well, this tag appears invalid, not that it has anything to do with the problem: <center/> and you never close the center tag off Aside from that are you getting errors etc.? You say you "know" your code is correct, yet it does not work... either you or your code is wrong I will assume you have connected to the db somewhere outside of your code, have you tried to echo out the query to see if it looks right? You could also then run the query with something like phpmyadmin to see if it runs directly against the db. As I look a bit closer, what you're doing in the if doesn't make much sense, could you post the rest of the code? Quote Link to comment Share on other sites More sharing options...
edrew04 Posted October 6, 2009 Author Share Posted October 6, 2009 Well, this tag appears invalid, not that it has anything to do with the problem: <center/> and you never close the center tag off Aside from that are you getting errors etc.? You say you "know" your code is correct, yet it does not work... either you or your code is wrong I will assume you have connected to the db somewhere outside of your code, have you tried to echo out the query to see if it looks right? You could also then run the query with something like phpmyadmin to see if it runs directly against the db. As I look a bit closer, what you're doing in the if doesn't make much sense, could you post the rest of the code? yeah, i echoed my table, but when it comes to search, i only want the id which is 1 to be shown, but other id's are showing even they were not id number 1. it shows that, my search query is as the same as my echo the whole table Quote Link to comment Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 Is the type of Physician_ID integer? If so try... mysql_query("SELECT * FROM physicians WHERE Physician_ID=" . $_POST['pat5']) or die (mysql_error()); 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.