Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-11-2012, 07:30 AM   PM User | #1
predoctail
New to the CF scene

 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
predoctail is an unknown quantity at this point
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
predoctail is offline   Reply With Quote
Old 02-11-2012, 01:44 PM   PM User | #2
PHP6
Regular Coder

 
PHP6's Avatar
 
Join Date: Aug 2008
Location: Czech Republic
Posts: 234
Thanks: 17
Thanked 34 Times in 33 Posts
PHP6 is on a distinguished road
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
PHP6 is offline   Reply With Quote
Old 02-11-2012, 10:23 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is online now   Reply With Quote
Reply

Bookmarks

Tags
mysql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:59 AM.


Advertisement
Log in to turn off these ads.