【 tulaoshi.com - PHP 】
<HTML<BODY BGCOLOR=FFFFFF
<?php
echo "Connecting as mysql<BRn";
$connection1 = mysql_connect('localhost', 'mysql', '') or die($php_errormsg);
echo "connection1 is $connection1<BRn";
echo "Selecting test for mysql user<BRn";
mysql_select_db('test', $connection1) or @die("Error " . $php_errormsg . mysql_error());
echo "Connection as joyce<BRn";
$connection2 = mysql_connect('localhost', 'joyce', '') or die($php_errormsg);
echo "connection2 is $connection2<BRn";
echo "Selecting books for joyce user<BRn";
$db2 = mysql_select_db('techbizbookguide', $connection2) or die(mysql_error());
$query1 = "select foo from test";
$query2 = "select title, authorFirst, authorLast from bookinfo";
echo "Querying test<BRn";
$users = mysql_query($query1, $connection1) or die(mysql_error());
echo "Querying books<BRn";
$books = mysql_query($query2, $connection2) or die(mysql_error());
echo "Foos from test<BRn";
while (list($foo) = mysql_fetch_row($users)){
echo $foo, "<BRn";
}
echo "Books in techbizbookguide<BRn";
while (list($title, $authorFirst, $authorLast) = mysql_fetch_row($books)){
//Use trim in case we have a book by "Madonna" or "Prince" or...
echo $title, ' by ', trim($authorFirst . ' ' . $authorLast), "<BRn";
}
?
</BODY</HTML