Insert to MySQL inside foreach


Posted on 16th Feb 2014 07:03 pm by admin

Hey.
I am parsing some html, and putting inside an html db.
I need to create a randomized integer to be a unique identifier, and i chose just to use time().

But I foreach the results, and inside here i do the inserting.
But when i call time() in foreach, it'll be the same for every entry parsed.

foreach code:
Code: foreach($linjerMatches[1] as $k=>$v) {
echo $fylke." <b>".$linjerMatches[1][$k]."</b> ".time()."<br />";

//$sql = "INSERT INTO ruteinfo_linjer(fylke,identifier,linje) VALUES('".$fylke."', '".time()."', '".$linjerMatches[1][$k]."')";
//$result = mysql_query($sql, $linkID) or die("Error");
}
time() will output the same for every row. How can i fix that?

No comments posted yet

Your Answer:

Login to answer
306 Like 53 Dislike
Previous forums Next forums
Other forums

dropdown box help - open php files to textarea
Hi, I am using tinymce to edit content located in several php files. The code I attached works but i

Question about the upload of large files
Hi there,

I have a question about the upload of large files, like videos (files generally abo

Aris, Netweaver BPM, Visual composer and X'app
Dear Experts,

Whats the relationship between the following components: Aris, Netweaver BP

What's best way to get a user's Word doc converted to simple html and images?
Hi all,

I was just wondering if anybody has any experience of this.
Basically, I'm buildin

PHP and Javascript
Hello Everyone,

I have a page that needs a javascript code to be written between PHP code but

Suggestions for Functional module
Hello experts,
I Have done B.Sc(Mathematics) and MCA & have learnt SAP/ABAP but do n

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

help me, how to find text on an external html site using PHP
Would anyone know how to search an external html file for a work or phrase ?

I was thinking s

Blocking video streaming
Hello everyone,

I post a message here because i didn't find any solution yet.
I just finis

Storing the referrer in session... problems with tabs
Hello All

I am currently working on an ERP project based on the MVC methodology, when a user

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash