Upload excel file in MYSQL using PHP -
i want upload excel file mysql table without using pdo, simple mysql connection.
i want load excel file using domdocument::load
can't work.
here's i've tried far:
mysql_connection("localhost", "root", ""); mysql_select_db("excel"); function add_data($abc, $pqr, $xyz) { $str = "insert excel(abc, pqr, xyz) values('$abc', '$pqr', '$xyz')"; $qry = mysql_query($str); } if (isset($_files['file'])) { $dom = domdocument::load($_files['file']['tmp_name']); $rows = $dom->getelementsbytagname('row'); $first_row = true; foreach ($rows $row) { if (!$first_row) { $abc = ""; $pqr = ""; $xyz = ""; $index = 1; $cells = $row->getelementsbytagname('cell'); foreach ($cells $cell) { $ind = $cell->getattribute('index'); if ($ind != null) $index = $ind; if ($index == 1) $abc = $cell->nodevalue; if ($index == 2) $pqr = $cell->nodevalue; if ($index == 3) $xyz = $cell->nodevalue; $index += 1; } add_data($abc, $pqr, $xyz); } $first_row = false; } }
Comments
Post a Comment