MySQL Loop

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
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
Close
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
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back