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
https://forums.phpfreaks.com/topic/46367-solved-array-to-individual-rows-in-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.