Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. bob schmuckatelli
  2. jane doe
  3.  
  4. id Fname Lname addr something
  5. 214 jack frost 444 snow rd data data
  6.  
  7. $file = fopen('names.txt','r'); //change to whatever name it is
  8. $firstname = ''; $lastname = ''; $index = -1; $id = -1;
  9. $tab = ' '; //change this to the delimiter, of course
  10. while ($line = fgets($file)) {
  11. $index = strrpos($line, $tab);
  12. $firstname = substr($line, 0, $index);
  13. $lastname = substr($line, $index + strlen($tab));
  14. $id = $sql->query("SELECT id FROM db_name WHERE Fname='" . $firstname . "' AND Lname='" . $lastname . "'");//query the firstname/lastname. Change db_name to whatever and I'm assuming you don't need to sanitize.
  15. //do something with the id?
  16. }
  17. fclose($file);
  18.  
  19. id fname lname addr age
  20. N michael jordan N N
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement