I generated a random monster team from a table, and limited by 6. Now, I also want to insert the team into user_team which contains the fields m1,m2,m3,m4,m5,m6
Those represent Monster 1 to Monster 6. Now when I try to insert the generated monsters into the team, only the last Monster seems to be inserting into it while I all of my monsters to be inserted. http://prntscr.com/8zrj2
$sql = "SELECT * from monsterdata ORDER BY RAND() LIMIT 6";
$result = mysql_query($sql);
// this checks if you have a result
if ($result == null) echo "No result";
else {
while (($row = mysql_fetch_array($result)) != false) {
$row = mysql_fetch_array($result);
{
// html code here
}
}
the Insert statement is
$monster = $row['id'];
$sql = "INSERT into user_team(m1,m2,m3,m4,m5,m6) VALUES('$monster','$monster','$monster','$monster','$monster','$monster')";
$result = mysql_query($sql);
Just don't know where/how to place it so it inserts the right values into the right columns.