Well notepad++ is an interesting program with lots of potential uses but for what I am doing I think i can create loottables just as fast without it.
I took the script segment trevius posted and started trying to adapt it to what I was working on. While I have made some progress I am still unable to get the id to transfer through. Here is where I am at now
Code:
#Item id look up by item name
$tablename = "items";
$columnname = "Name";
use DBI;
use DBD::mysql;
# Set Database Connection
my $connect = DBConnect();
open (FILE, 'data.txt');
while (<FILE>) {
chomp;
if ($_)
{
$query = "Select id from $tablename where $columnname = '$_'";
}
# Prepare and Execute the Query
$query_handle = $connect->prepare($query);
$query_handle->execute();
open (MYFILE2, '>>data2.txt');
print MYFILE2 "INSERT INTO `lootdrop_entries` (`lootdrop_id`, `item_id`, `item_charges`, `equip_item`, `chance`) VALUES (x, $id, 1, 0, z); /* $_ */\n";
}
close (MYFILE);
close (MYFILE2);
sub DBConnect {
# Configuration Settings
my $database = "peq";
my $host = "localhost";
my $port = "3306";
# Set Connect String
my $dsn = "dbi:mysql:$database:$host:$port";
my $user = "root";
my $pw = "password";
# Set Database Connection
my $connect = DBI->connect($dsn, $user, $pw);
return $connect;
}
I am not sure how to pull the id values out of the select statement. Only reason I got the name to go through was because of a default to $_ when reading the file text. Any hints would be welcomed.