Results 1 to 3 of 3

Thread: How to create loop query sql ?

  1. #1
    Join Date
    May 2009
    Posts
    22

    How to create loop query sql ?

    I want to retrieve emails in a text file and insert these emails in SQL queries to deal with.

    Code:
    Here is my case: 
      $ fp = fopen ( "$ file", "r") / / We open the file 
    
      while (! feof ($ fp))  
      (  
      $ line = fgets ($ fp, 255) / / It gets the lines of the file (emails ..) 
    
      mysql_query ( "UPDATE members SET email = NULL WHERE email = '$ line'"); 
    
      echo $ line. '<br />'; 
      )
    Problem is that above query does not work. emails are not deleted from database.

    Can you help me ?


    Thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    10

    Re: How to create loop query sql ?

    fgets function returns an entire line of a file, up to meet a newline (character \ n). The problem is precisely that it returns the \ n with! So in your comparison between the field of comics and the variable $ line, and you are with a character too

  3. #3
    Join Date
    Dec 2008
    Posts
    28

    Re: How to create loop query sql ?

    Transact-SQL statement or statement grouping as defined with a statement block. To define a statement block, use the control-of-flow keywords BEGIN and END.

    BREAK

    Causes an exit from the innermost WHILE loop. Any statements that appear after the END keyword, marking the end of the loop, are executed.

    CONTINUE

    Causes the WHILE loop to restart, ignoring any statements after the CONTINUE keyword.

    Example

    Code:
    DECLARE Employee_Cursor CURSOR FOR
    SELECT EmployeeID, Title 
    FROM AdventureWorks.HumanResources.Employee
    WHERE ManagerID =3;
    OPEN Employee_Cursor;
    FETCH NEXT FROM Employee_Cursor;
    WHILE @@FETCH_STATUS = 0
       BEGIN
          FETCH NEXT FROM Employee_Cursor;
       END;
    CLOSE Employee_Cursor;
    DEALLOCATE Employee_Cursor;
    GO

Similar Threads

  1. Create batch file to run access query
    By DeMario in forum Software Development
    Replies: 5
    Last Post: 31-12-2009, 04:44 AM
  2. How to create a query on datagrid view in vb.net
    By Ainsley in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 09:59 PM
  3. Create FLV video loop
    By Dyumani in forum Windows Software
    Replies: 3
    Last Post: 19-05-2009, 11:16 AM
  4. How to create 7 days query in MySql
    By Patrickboy in forum Software Development
    Replies: 2
    Last Post: 18-05-2009, 02:02 PM
  5. How to create a script in a DOS batch file to do a loop?
    By Jon Osborn in forum Windows Server Help
    Replies: 2
    Last Post: 27-05-2008, 06:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,002,879.83569 seconds with 17 queries