Tom Read Posted July 12, 2010 Share Posted July 12, 2010 Hi all, currently being taught PHP in Computing at school and been set a task to do. I've grasped it all pretty quickly, but now I'm stuck! I have a database full of people's names and addresses etc. and need to create a drop down menu of their names, hit a search button, and for all their details to come up. I have all the names in the drop down menu and then I've managed to split that back into Forename and Surname using so I am able to do... WHERE Forename = $find_forename AND Surname = $find_surname (as putting them together into a drop down menu merges them together so it no longer knows that it's 2 different parts). I'm not sure how to pull out the data of that one person however, as I already have accessed the database in order to display their names, if that makes sense. So I need to hit the search button, then have my code pull out that one person's data and display that, with the drop down menu still showing. If someone could explain where I'm going wrong or what needs to be done, would be much appreciated! I don't know if that makes sense or not, probably not! Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/207536-searcing-a-database-im-new-to-php/ Share on other sites More sharing options...
jackrabb1t Posted July 12, 2010 Share Posted July 12, 2010 Sounds like what you're looking to do could be accomplished with AJAX. Take a look at this: http://www.w3schools.com/PHP/php_ajax_database.asp Quote Link to comment https://forums.phpfreaks.com/topic/207536-searcing-a-database-im-new-to-php/#findComment-1085061 Share on other sites More sharing options...
radar Posted July 12, 2010 Share Posted July 12, 2010 This can be done in straight PHP as well. Since you've managed to split the forename and surname back up out of the drop down menu this is really simple. After you split the names you basically re-query the database like: $sql = "SELECT * FROM table WHERE Forename = '".$forename."' AND Surname = '".$surname."'"; $data = mysql_query($sql); $data = mysql_fetch_array($data); and from there you can echo it out like: echo $data['Forename']; echo $data['Surname']; etc... and of course you can throw it into tables if you want too. Quote Link to comment https://forums.phpfreaks.com/topic/207536-searcing-a-database-im-new-to-php/#findComment-1085078 Share on other sites More sharing options...
Tom Read Posted July 12, 2010 Author Share Posted July 12, 2010 I would let you know if it's worked or not, but my XAMPP control panel won't start Apache. Keeps saying WARNING terminating worker thread 0. Best try and fix it! Quote Link to comment https://forums.phpfreaks.com/topic/207536-searcing-a-database-im-new-to-php/#findComment-1085098 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.