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

SHOW TABLES Help
Hi all

I have the following

Code: [Select]<?php
$sql = "SHOW TABLES&quo

Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below.
$.ajax({

Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very

problem when runing a funciton
I am trying to connect to database using a funciton in a functions.php

<?php
funct

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

How to display objects in a row
I have 7 codes that i want to display in a row one next to another.
The first is {$ads->ad

Require select-option functionality in Module Pool Programming
Hi Gurus,

I am doing a development by Module Pool on Warehouse Management. For that devel

how to timeout $doc = new DOMDocument()->load($url)
I am currently using this $doc->load($url) to fetch an rss feed.
If a feed takes long than

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