Codi Posted November 5, 2007 Share Posted November 5, 2007 I have created a small MySQL database named test with FirstName, LastName & Age as the fields. What I have been trying to do very unsuccessfully is to create a query file that will be the back end of the following:- <html> <body> <form action="results.php" method="post"> First Name: <input type="text" name="FirstName" /> Last Name: <input type="text" name="LastName" /> Age: <input type="text" name="Age" /> <input type="submit" /> </form> </body> </html> I can get the results.php file to return results when I enter a first name, last name or age in the entry form, but the results.php form only retrieves the the one that I requested (first, last or age). What I have been trying to do is to get it to retrieve all the information from that record if I only enter the first name or last name or age etc or if I enter any combination of the three. But regardless of which one or combination I enter, those in particular are all I can get it to return. I must apologize for being so stupid. You see I use to be a top notch programmer, then I had a great heart attack and lost most of my long term memory (my coding ability must have been at the top of the list) so now I am trying to get some of it back. I have been working on this problem for over a week, digging through my books but I haven't come up with a solution so if it isn't too much trouble, possibly you could give me a hand? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 5, 2007 Share Posted November 5, 2007 Well, perhaps if you show us the code you have used so far, we might be able to point out what needs changing. Post it up inside tags(without the spaces) and we'll take a look. Quote Link to comment Share on other sites More sharing options...
Codi Posted November 5, 2007 Author Share Posted November 5, 2007 The config file contains <?php $dbhost = 'localhost'; $dbname = '****_db'; $dbuser = '****_user'; $dbpass = '*****'; ?> [code}<?php include ("includes/config.php") ?> <?php if (isset($_POST)) { if (isset ($_POST['FirstName'])) { $FirstName = addslashes($_POST['FirstName']); } if (isset ($_POST['LastName'])) { $LastName= addslashes($_POST['LastName']); } if (isset ($_POST['Age'])) { $Age = addslashes($_POST['Age']); } } ?> <?php // Connects to your Database include 'includes/opendb.php'; mysql_select_db("$dbname") or die(mysql_error()); $result = mysql_query("SELECT * FROM test WHERE FirstName LIKE '$FirstName' AND LastName LIKE '$LastName' AND Age LIKE '$Age'"); //And then..... mysql_query($query, $conn); //And sometimes you have to use your link code in here ?> <html> <body> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="274" height="114"> <tr> <td width="274" height="114" align="center" valign="top"> <p align="left"><?php echo $_POST["FirstName"]; ?> <?php echo $_POST["LastName"]; ?>, You are welcome to join others on this quest.</p> <p align="left">Providing that you are at least <?php echo $_POST["Age"]; ?> years old. </td> </tr> </table> </center> </div> </body> </html> {/code} 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.