Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Thanked 0 Times in 0 Posts

    Smile Mysqpl while loop

    Hi, I am newbie
    Can Some one help me to take out from my problem

    I have two tables in database first allinfo and second string
    in first table i have all the info about customer
    and in second table i have two column first email<foriegn key> second string<as per moderators view>

    I want to display all the records including string of second table dynamically
    by while loop increment

    can anyone solve my problem here ..
    Plz help.............


  2. #2
    Regular Coder PHP6's Avatar
    Join Date
    Aug 2008
    Czech Republic
    Thanked 34 Times in 33 Posts
    Hi, let me clear the question:

    You have two tables. The first one includes information about customers which are registered within your system. The second table contains two columns, the first one is email (I guess unique value) and second one is string (I guess text type). You want to display all records, am I right?

    Could you please tell us how these two tables are connected with each other? I guess you will have email column in first table as well which should be used to link them together, am I right? Also could you please tell us why do you want to use loop and what are you trying to implement. May be there will be simper solution than query loop.

    Waiting for your reply

  3. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    The only way to use a WHILE loop in MySQL is to create a stored procedure. I don't think that is what you need here. I think what you probably really want is a WHILE loop in PHP (or ASP or JSP or ... ) code.

    If that's so, then it's easy:
    SELECT allinfo.*, string.string
    FROM allinfo LEFT JOIN string
    ON allinfo.email = string.email
    ORDER BY allinfo.??? [you choose]
    Be yourself. No one else is as qualified.


Tags for this Thread

Posting Permissions

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