I tried to summarize it on my title but let me explain you what I am trying accomplish in more details below.
Currently I pass an array to my query and use a foreach to insert each array in to my db as shown below.
if(is_array($myArr)){
foreach($myArr as $userID=> $email){
$sql = "INSERT INTO userdata (userID, email) values ('$userID', '$email')";
mysql_query($sql) or exit(mysql_error());
}
}
Currently my array looks the following
Array
(
[39] => [email protected]
[54] => [email protected]
[55] => [email protected]
[56] => [email protected]
[57] => [email protected]
[58] => [email protected]
[59] => [email protected]
[60] => [email protected]
[61] => [email protected]
[62] => [email protected]
[63] => [email protected]
[64] => [email protected]
)
with the '$userID' being [39] and 'email' being the..well email.
This is where my question comes in.
What I want to achieve is insert a new id in a new column in I have called 'url' in this 'url' column I want to be able to increment by 1 and add the same value to the row with the same email.
So something like this.
UserID | email | url
===============================
39 | [email protected] | 1
54 | [email protected] | 1
55 | [email protected] | 1
56 | [email protected] | 1
57 | [email protected] | 2
58 | [email protected] | 2
59 | [email protected] | 2
60 | [email protected] | 2
61 | [email protected] | 3
62 | [email protected] | 3
63 | [email protected] | 3
64 | [email protected] | 3
I'm hoping this makes sense. Thank you for reading. Always appreciate the help.
id, email(in which id holds the autoincrement column), and a table withuserId,url?