Re: RE: select inside a while loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, just say the message.

> Your code looks well. But is the variable $db the name of your database or
> your link-identifier. When it is the name of your database i'm not really
> surpised your code wouldn't work. mysql_query requires as second argument a
> link identifier.

Read what Rolf says. Very wise words here. :-)

> So with all that said here is what i have done that doesn't work,
> 
> $result = mysql_query("SELECT artist_id FROM songs",$db) or
> die(mysql_error());
> 
>    if ($row = mysql_fetch_row($result)){
>        do {
> 
> $artist_name = $row["artist_id"];
> $result_1 = mysql_query("SELECT artist_id,artist_name FROM
> artists WHERE artist_name = '$artist_name'",$db);
> $row_1 = mysql_fetch_array($result_1);

Why don't you make one query with a union between the 2 tables and then pass 
through the results with a loop and maybe an if inside it? Ypou are making to 
many connections to the DB.

P.D.: Any way, your problem will be solved with Rolfs advice.

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-----------------------------------------------------------------
Martín Marqués                  |        mmarques@xxxxxxxxxx
Programador, Administrador, DBA |       Centro de Telemática
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux