šŸ“ˆ Adding users from a CSV file to a MySQL database

I recently encountered an issue requiring me to import about 500 employees into a database and add each one to multiple departments. Using an array, I wrote some pretty simple code to import a CSV file that simply contained ā€œusername, real nameā€ into the database. I wanted to post it in case anyone ever needed to do something along these lines. <?php include('../config.php'); $departments = array("department1", "department2", "department3", "department4"); mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbase") or die(mysql_error()); $handle = fopen("employees.csv", "r"); while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) { foreach ($departments as &$value) { $query = "INSERT INTO employees (`id`, `name`, `realname`, `tickets`, `dept`) VALUES (NULL, '$data[0]', '$data[1]', '0', '$value')"; $result = mysql_query($query) or die(mysql_error()); echo $data[1] . ' successfully added to ' . $value . ' department<br>'; } } unset($value); ?>

April 27, 2010 Ā· 1 min Ā· 133 words Ā· shelby

Raid Solution

I am in search of a raid solution. I have been pretty interested in the Drobo but due to the cost of what you get I am not sure its the best method, though the idea is cool. I am thinking instead of maybe getting a few 1tb+ drives and a cheap RAID card and tossing it all into my Linux box as it would provide a lot more than just a storage device, not to mention the cost would be much less. ...

January 19, 2010 Ā· 1 min Ā· 83 words Ā· shelby

Yup

January 14, 2010 Ā· 0 min Ā· 0 words Ā· shelby

1yr in Vegas

The date had almost slipped me by.Ā I have now been living in Vegas for 1yr, 6 months longer than I really would have cared for.Ā I moved to Vegas to get out of computers for a bit and attempt to work at one of the many clubs or casinos… And if you know where I stand now, and you know that didn’t happen. Instead, I ended up working for a company that provides support for all of the casinos and bars. ...

April 3, 2009 Ā· 1 min Ā· 136 words Ā· shelby

🚬 5 Smokes and counting ...So

with the recent price hike of cigarettes, I have decided my time to quit is now.Ā I have 5 more left in my pack, which I can only assume I will finish before I go to bed tonight.Ā That being the case, I am no longer going to purchase packs; I mean, who can afford to buy them at $6 something a pack?Ā Not to mention the money I will save over the course of a year.Ā Depending on the day, I smoke about half a pack, which leads me to buy a pack a day so that I always have some.Ā ...

April 1, 2009 Ā· 1 min Ā· 140 words Ā· shelby