Skip to content
WJunction - Webmaster Forum

insert 100 urls to database in one go ?

Status
Not open for further replies.
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.

About the author

J
Active Member · Joined
Searching the internet
45
Messages
0
Reactions
6
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom