Insert to MySQL inside foreach

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

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

Checking if field is empty AND using !is_numeric
Hi lads,

Need to be able to display an error message (using isset?) that says "Cant lea

Blocking video streaming
Hello everyone,

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

Handling text changed in text box control using Ajax
I need to create a web form with a text box control. When someone types text into the textbox I nee

Sending UDP Raw socket
I truly need help on this. I am trying to write a test program that simulate a network environment

A little help in c#
i am doing a simple paint program using c# i want to draw with the mouse so i wrote the code of the

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