Jump to content

[SOLVED] Array to individual rows in MySql


pro_se

Recommended Posts

Wow, I don`t know what I would do without all of you, you all have helped me so much... Anyways, I have another problem that I am sure you all can figure out...

 

I am currently attempting to insert user tags into a table on my database, I am using an WHILE statement to do this but PHP is acting fishy and its only inserting one of my array elements...

 

Here is my code:

function initialsetup($gender, $byear, $bmonth, $bday, $orientation, $tags, $uid) {
if (($byear<1900)OR($byear>2100)) {
header("Location: http://notexting.com/initial_setup");
} elseif (($bmonth<=0)OR($bmonth>12)) {
header("Location: http://notexting.com/initial_setup");
} elseif (($bday<=0)OR($bday>31)) {
header("Location: http://notexting.com/initial_setup");
} else {
$eachtag = explode(", ", $tags);
$repeat = 0;
while (count($eachtag) > $repeat) {
$uid = $_SESSION['userid'];
$query = "INSERT INTO `tags` ( `uid` , `tag` ) VALUES ('$uid', '$eachtag[$repeat]')";
$insert_tags = mysql_query($query);
$repeat++;
}
}
}

 

Please help! I am putting like 30 tags into the form and only one tag is being inserted into the DB!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.