banana_joe_II Posted January 26, 2006 Share Posted January 26, 2006 Hi Everyone!As already state im a complete newbie to this so bear with me please =)Im working on school project with a php script that is supposed to show data from a SQL Database (Table). Getting the script to show data from the database is no problem if i "hard code" it in the script.... However, i want the user to be able to request specific data through an input field. See below:<?php$email = $HTTP_POST_VARS["email"];if( $HTTP_POST_VARS["email"]!= "");else{ echo ("Clicken Sie in Ihrem Browser zurück und füllen Sie bitte Alle Felder Aus!");}{$result = mysql_query("SELECT * FROM buchen WHERE email='HTTP_POST_VARS["email"]' ORDER BY 'id'");while($row = mysql_fetch_array($result))echo "# ";echo "<BR>", $row["name"];echo "<BR>", $row["tel"];echo "<BR>", $row["email"];echo "<BR>", $row["abflug"];echo "<BR>", $row["dest"];echo "<BR>", $row["datum"];echo "<BR><HR>";}mysql_close();?>Connecting to the database works fine and everything and i did not include the html form im using but i triple checked... the field is named "email" The bit i think where the problem is, is colored red....does anyone have an idea? thanks for the help, joe Link to comment Share on other sites More sharing options...
Selacius Posted January 26, 2006 Share Posted January 26, 2006 First off, I am not sure what your trying to do with the If statement. I would personally write your code like this: <?phpif ($HTTP_POST_VARS["email"] != ""){$email = $HTTP_POST_VARS["email"];}else {echo ("Clicken Sie in Ihrem Browser zurück und füllen Sie bitte Alle Felder Aus!");}$result = mysql_query("SELECT * FROM buchen WHERE email=$email' ORDER BY 'id'");while ($row = mysql_fetch_array($result)){echo "# ";echo "<BR>", $row["name"];echo "<BR>", $row["tel"];echo "<BR>", $row["email"];echo "<BR>", $row["abflug"];echo "<BR>", $row["dest"];echo "<BR>", $row["datum"];echo "<BR><HR>";} You forgot to open the while tag, so it wasn't really looping through anything. This should work like you want it to. Link to comment Share on other sites More sharing options...
banana_joe_II Posted January 27, 2006 Author Share Posted January 27, 2006 (What i want to do is for the user to be able to look into the data he has entered previously by now entering his email which is stored in the database.)Thanks for the correction.... I also added the missing " ' " in the sql query. It finally works now! Thanks a lot... What i ultimately wanted to do is have the information that is now merely being displayed entered automatically in the appropriate fields in a form so it can be corrected by the user and sent off again....Anyone have ideas how that might work? It might be a little too complicated so maybe I'll just put a link back to the original (empty) form for the user to fill out again...thanks again, joe Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now