NameSilo

MySQL Loop

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
NamecheapNamecheap
Watch

AzN

VIP Member
Impact
135
I'm having trouble with a mysql loop.

I have three tables.

I need to query the first table, then it queries the second table, and it needs to loop the data from the third table.

Here is how I do it.

$id = $_GET['id'];

SELECT * FROM table_1 WHERE id='$id'

$row2 = $row['id_2'];

SELECT * FROM table_2 WHERE id='$row2'

$row3 = $_row['id_3'];

This is where I would use the while() loop and SELECT * FROM table_3 where id='$row3'

BUT..... it only prints out the FIRST value even thought I put a mysql_fetch_array loop.

Any help is appreciated.
Thanks! :laugh:
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
could you post more code so we could see.

Also have you tried echoing out the last query to see if it as expected then running it through phpmyadmin too see how many results are actually returned.
 
0
•••
Why would there be more than one row if you are selecting by id?


You could try mysql_fetch_assoc instead.
PHP:
while ($row = mysql_fetch_assoc(mysql_query("SELECT * FROM table_2 WHERE id='$row2'"))) { ... }
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back