Jump to content

Recommended Posts

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. 

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);
}

?>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.