flor Posted May 4, 2007 Share Posted May 4, 2007 Hi guys, I'm pretty new at this, and I'm trying to make a very simple script. It is not doing what I want This is my code: $query="SELECT id, lastname, firstname FROM patient ORDER BY lastname"; $result = mysql_query ($query); $display_block = "<select name=\"patientnr\">"; while($nt=mysql_fetch_array($result)){ $display_block .= "<option value=\"$nt[id]\">$nt[lastname] $nt[firstname]</option>"; } $display_block .= "</select>"; This part works! hurray! Now the page it directs me to is not working: $query="SELECT id, lastname, firstname FROM patient WHERE id = '{$_POST['patientnr']}'"; $display_block = "<p>$id</p><p>$lastname</p><p>$firstname</p>"; This always returns an empty result. Can anyone see why? Quote Link to comment Share on other sites More sharing options...
taith Posted May 4, 2007 Share Posted May 4, 2007 $result=mysql_query("SELECT id, lastname, firstname FROM patient ORDER BY lastname") or die(mysql_error()); $display_block="<select name=\"patientnr\">"; while($nt=mysql_fetch_assoc($result)){ $display_block.="<option value=\"$nt[id]\">$nt[lastname] $nt[firstname]</option>"; } $display_block.="</select>"; Quote Link to comment Share on other sites More sharing options...
flor Posted May 4, 2007 Author Share Posted May 4, 2007 Hi, The first part actually works, it returns this html: <form id="selectpatient" name="selectpatient" method="post" action="getpatient.php"> <p><select id="patientnr" name="patientnr"><option value="1">patient pete</option><option value="2">patient paul</option></select></p> <p> <input type="submit" name="Submit" value="Submit" /> But if I click submit, I get an empty result, where I think I should be getting the details of patient with option value=1 or 2 Quote Link to comment Share on other sites More sharing options...
Silverado_NL Posted May 4, 2007 Share Posted May 4, 2007 is the ACTION filename right??? are you expecting the $_POST vars??? did you close all the options??? did you close the FORM???? Greetz Silverado Quote Link to comment Share on other sites More sharing options...
flor Posted May 4, 2007 Author Share Posted May 4, 2007 is the ACTION filename right??? did you close the FORM???? 2 x yes are you expecting the $_POST vars??? did you close all the options??? what do you mean by these questions? 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.