inVINCEable Posted June 18, 2007 Share Posted June 18, 2007 I want to insert the names of these links into my MySQL database, and assign them an auto-incrementing id number. The auto-increment isn't a problem, I want to know if there is a way to insert the names of these school names, without having to type them in individually which would be a very painstaking process. http://en.wikipedia.org/wiki/Category:High_schools_in_Indiana Thank you for any advice. Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/ Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 ya but that also a long process Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/#findComment-276556 Share on other sites More sharing options...
pocobueno1388 Posted June 18, 2007 Share Posted June 18, 2007 What is so hard about putting all the names in individually? All you have to do is copy and paste a chunk of them at a time, it would take 7 minutes to get them all into an array. I think it would actually take longer to try and figure out how to do it the way you are wanting....but you can wait and see if someone can point you in the right direction if you want to. <?php //Add all the schools to this list, and make sure to put a comma after each one. $schools = " Barr-Reeve Junior-Senior High School, Bedford North Lawrence High School, Ben Davis High School, Benjamin Bosse High School, Benton Central Junior-Senior High School, Bethany Christian Schools, Bishop Chatard High School"; //put the schools in an array $list = explode(",", $schools); //Loop through each school adding it to the database foreach($list as $key){ $key = mysql_real_escape_string(trim($key)); $query = "INSERT INTO schools (name) VALUES ('$key')"; mysql_query($query); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/#findComment-276566 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 I thought what the other guy is pointing out is that read the page just like the link he gave us and let the code insert those text in there Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/#findComment-276568 Share on other sites More sharing options...
pocobueno1388 Posted June 18, 2007 Share Posted June 18, 2007 Geez...I am having issues with reading posts today. Sorry about that, I edited my post. It's not much of a change, but it addresses the issue better. Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/#findComment-276569 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 doing your code simply mean coding it in the array so you will also code them right?? but any way your code is right and that will some how help if thats what the poster of this topic mean. well i just thought that it will work the same as the way i created my xml parser wherein read the page and get those data in there and store in the array any way i don want to eloborate those looks pretty long to discuss Quote Link to comment https://forums.phpfreaks.com/topic/55992-insert-names-of-schools-based-upon-list-into-mysql-automatically/#findComment-276570 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.