Welcome Guest, Not a member yet? Register   Sign In
Favorite Movies : Need help with a tiny scripts
#2

[eluser]Mischievous[/eluser]
I would use a 2 table setup in your database and not run with a commas separated field.

For example:

Users_table: id, name

Movies_table: id, user_id, movie

Then on the input form just grab the movies list... run your

Code:
$moviesArr = explode(",",$_POST['movies']);

Then just do a while or for loop to run through the array and insert each movie into the database corresponding with the user_id.

Code:
for($i = 0; $i <= count($moviesArr)-1; $i++)
{
  $query = "INTO movies (user_id, movie) VALUES ('$user', '$moviesArr[$i]')";
  $queryresult = mysql_query($query);
  if($queryresult){
     echo($moviesArr[$i]."Movie added to database, thanks for your submission");
  }else{
     echo("There was a problem adding ".$moviesArr[$i]." into the database");
  }
}


Messages In This Thread
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 10:54 AM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 11:13 AM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 11:27 AM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 11:37 AM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 11:46 AM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 12:09 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 12:32 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 12:33 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 12:35 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 02:35 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-19-2009, 03:25 PM
Favorite Movies : Need help with a tiny scripts - by El Forum - 06-20-2009, 02:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB