Posted by Mahmoud Babli on 10/12/06 16:26
Lucas Byers wrote:
> Hey all,
>
> I'm trying to create a php tool for local use where I put a
> list of words (one on each line) in to a textbox and it takes each word
> and creates an entry in an sql table.
>
> So I'd put
>
> hey
> ho
> whats
> up
> yes
> no
> maybe
>
> and it'd go through each word and create a seperate entry so 1 for hey,
> 1 for ho, and so on.
>
> Is there a way to
>
> a) get how many rows there are in to php?
> b) select each row and grab it's contents?
>
> Thanks for your time.
>
I assume you are looking for something like this:
function readFileToDB($file)
{
if(!$fp=@file($file)) //$fp is an array of each line in $file
{
echo "FAILED-LEVEL-1";
exit;
}
for($i=0; $i<count($fp); $i++)
{
if(!$dp=sqlOperationInsert($fp[$i])
{
echo "FAILED-LEVEL-2";
exit;
}
}
$count = count($fp);
echo "SUCCESS, ENTRY COUNT WAS: $count\n";
}
function sqlOperationInsert($data)
{
// insert into database.
}
[Back to original message]
|