-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadData.php
More file actions
39 lines (31 loc) · 795 Bytes
/
loadData.php
File metadata and controls
39 lines (31 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$filename='firstnames.out';
$firstname = file($filename, FILE_IGNORE_NEW_LINES| FILE_SKIP_EMPTY_LINES);
//var_dump($firstname);
$filename2='lastnames.out';
$lastname= file($filename2, FILE_IGNORE_NEW_LINES| FILE_SKIP_EMPTY_LINES);
//var_dump($lastname);
if (!$link = mysql_connect('localhost', 'root', 'sid')) {
echo 'Could not connect to mysql';
exit;
}
if (!mysql_select_db('sid', $link)) {
echo 'Could not select database';
exit;
}
foreach ($firstname as $fname) {
$tempstr='';
$i=0;
foreach ($lastname as $lname) {
# code...
if($i!=0)$tempstr.=',';
$i=1;
$tempstr.="('$fname','$lname')";
}
$sql="INSERT ignore INTO `names`(`first_name`, `last_name`) VALUES $tempstr";
mysql_query($sql, $link);
echo '.';
}
$sql="";
mysql_free_result($result);
?>