Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    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.............

    Thanks

  • #2
    Regular Coder PHP6's Avatar
    Join Date
    Aug 2008
    Location
    Czech Republic
    Posts
    237
    Thanks
    18
    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
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 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:
    Code:
    SELECT allinfo.*, string.string
    FROM allinfo LEFT JOIN string
    ON allinfo.email = string.email
    ORDER BY allinfo.??? [you choose]
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    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
    •