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

PHP Search Issue
Hi, I am using the following code to search and return flights from a database. The user searches by

Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha

Why do I get this error?
Error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or

image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai

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

Material Master Update through BAPI - Follow up material not updated
Hi Experts,

I am updating the material master through a custom transaction using the BAPI

breaking a text file into paragraphs based on strings
I have a text file of email addresses that is all squished together. It looks like this:

abc

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

with clause
hi all, i have a big query that usually access the same table more than once. for example, i have s

$GPRMC and NMEA how to extract from report
Hi There,

Im a little bi lost and not sure where to start with this one, ive got a small gps

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