daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. How to do a foreach insert query for a field?
  2. $person = mysql_real_escape_string($_POST['person']);
  3.  
  4. foreach($person_array as $value)
  5. {
  6. $insert = "INSERT INTO people (Person)
  7. VALUES ('".$value."')";
  8.  
  9. $query = mysql_query($insert) or die ("Error: ".mysql_error());
  10.  
  11. }
  12.    
  13. $person = explode(',', $_POST['person']);
  14.    
  15. foreach($_POST['person'] as $value)
  16. {
  17.     $value = mysql_real_escape_string($value);
  18.     //your query here
  19. }
  20.    
  21. $person = $POST['person'];
  22. foreach($person as $value) {
  23.     $value = mysql_real_escape_string($value);
  24.     $insert = "INSERT INTO people (Person) VALUES ('$value')";
  25.     $query = mysql_query($insert) or die("Error: ".mysql_error());
  26. }
  27.    
  28. $person = mysql_real_escape_string($POST['person']);
  29.    
  30. $person = mysql_real_escape_string($_POST['person']);
  31.    
  32. $person = $POST['person'];
  33.    
  34. foreach($person as $value) {
  35.     $value = mysql_real_escape_string($value);
  36.     $insert = "INSERT INTO people (Person) VALUES ('$value')";
  37.     $query = mysql_query($insert) or die("Error: ".mysql_error());
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top