insert 100 urls to database in one go ?

Status
Not open for further replies.

jack3r

Active Member
45
2011
0
0
hello,
could anybody help me with this please.
im trying to add 100 urls (domain url) in to a data base but want to some how do it with one go. ?
so far i am having to insert them one by one and it taking a long time to do. :'(

tables:
Code:
url - yes - no

how to insert like so:
www.domain1.com - 0 - 0
www.domain2.com - 0 - 0
www.domain3.com - 0 - 0
and so on

thanks in advance
 
2 comments
Try this ;)

PHP:
<?php

$db = mysql_connect("localhost", "dblogin", "dbpass");
mysql_select_db("dbname");

$lines = file("links.txt");
foreach($lines as $line)
{
	$ins = mysql_query("INSERT INTO table SET url='$line', yes='0', no='0'"); 
}

mysql_close($db); 
?>
 
Status
Not open for further replies.
Back
Top