0

I have this db table where I want to store about 100-500 different jokes (small jokes max 500 characters).

CREATE TABLE  `jokes` (
 `Num` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `Text` TEXT NOT NULL
) ENGINE = MYISAM ;

What method I should use for the fastest upload to the db my jokes? One of these website's tutorials should be fine for me?
http://www.w3schools.com/php/php_mysql_insert.asp
http://www.tutorialspoint.com/php/mysql_insert_php.htm

Thanks

4

1 回答 1

0

我认为您的问题可能是:我怎样才能将 100 个文本项(可能来自文件)插入到数据库表中。

如果是上述情况,以下算法可能会有所帮助:

(1)将所有笑话放入一个文本文件中,每行一个笑话。
(2)使用 PHP 的文件函数,将所有行放入一个数组中:

$lines = file("jokes_file.txt");

(3)然后遍历行并处理并插入到数据库表中。

foreach( $lines as $line )
{
    echo( $line );
//  Process and Insert into Database Table
}
于 2013-10-04T01:09:38.757 回答