Results 1 to 3 of 3

Thread: [RESOLVED] insert inside while loop !!!

  1. #1

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    [RESOLVED] insert inside while loop !!!

    how can i write a insert command inside a while loop ?
    i did try like following code but its not working !!!

    Code:
    while($result=mysql_fetch_array($sql))
     {
     mysql_query(INSERT INTO ......);
     }
    Last edited by samsyl; Jun 2nd, 2009 at 08:24 AM.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: insert inside while loop !!!

    Is the problem with the loop or the actual query? What are you trying to do? Also the condition in the loop looks wrong.

    You run the query to get the results. Then you loop through the results to get the rows. So you should probably have something like this:

    PHP Code:
    $Query "Some SELECT query here";
    $ResultSet mysql_query($Query);
    while (
    $Row mysql_fetch_array($ResultSet)) {
        
    //do stuff here



    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member samsyl's Avatar
    Join Date
    Jun 2001
    Location
    London
    Posts
    338

    Re: insert inside while loop !!!

    thanks a lot for this tips. it was helpfull

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width