Jump to content

search query in mysql in php problem


edrew04

Recommended Posts

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());

}
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.