opening table 2 inside table1
| From: | John Taylor-Johnston | Date: | Thu, 23 Sep 2004 03:28:23 +0000 |
| Subject: | opening table 2 inside table1 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-197641@lists.php.net to get a copy of this message | ||
I want to open table 2 inside table1. See $sql2 below. I know this is illegal.
How can I work around this? Or can I? Lost cause?
John
$myconnection = mysql_connect($server,$user,$pass);
#mysql_select_db($db,$myconnection); #not necessary
$sql1 = 'select * from '.$db.'.'.$table.' order by district,number
asc';
$myconnection2 = mysql_connect($server,$user,$pass);
#mysql_select_db($db2,$myconnection2); #not necessary
$news = mysql_query($sql1); //desc => z-a
while ($mydata1 = mysql_fetch_object($news))
{
echo "$mydata1->district<br />$mydata1->meeting<br />$mydata1->time<br
/>\n";
$sql2 = 'select participant,biography,district from '.$db.'.'.$table2.'
where district=$mydata1->district';
$news2 = mysql_query($sql2); //desc => z-a
while ($mydata2 = mysql_fetch_object($news2))
{
echo "<li>$mydata2->participant</li>\n";
echo "<li>$mydata2->biography</li>\n";
}
}
mysql_close($myconnection);
mysql_close($myconnection2);