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

Impact of movement type 412 E on MAP
Hi

Usage of movement type 412 E is causing huge change in MAP .

Is there any r

PHP page is blank
Hi Everyone,

I have a site in which I am able to open the first PHP webpage in my browser but

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

RSS feed - FeedList for WordPress
Hi,

I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of

Echoing a Variable from a Object
How do I get a variable from the new User Class to echo out in this clasS?

class MyApp
{

that old Malformed Headers problem again!!!!! HELP!!!!!!
I've read the http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

I don't think my c

Forms Authentication and Refresh at Login page
Hello, When I try to press the Login button in my webapplication at my login.aspx page nothing h

IDOC error
Hi, When i send IDOC from ECC system to MII there is no problem ECC side, i says message sent succe

Help Ordering Arrays
Hi, I have 3 arrays as shown below.

Code: $users = $this->get_latest_users();
$flir

Adding post count
How would I make it so everytime someone clicks submit on my form, their row in the database for the

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