echo "作為 MySQL
n 連結";
$connection1 = mysql_connect('localhost', 'mysql', '') 或 die($php_errormsg);
echo "connection1 是 $connection1
n";
echo "為 mysql 使用者選擇測驗
n";
mysql_select_db('test', $connection1) 或 @die("Error " . $php_errormsg . mysql_error());
echo "連接為 Joyce
n";
$connection2 = mysql_connect('localhost', 'joyce', '') 或 die($php_errormsg);
echo "connection2 是 $connection2
n";
echo "為 Joyce 使用者選擇書籍
n";
$db2 = mysql_select_db('techbizbookguide', $connection2) 或 die(mysql_error());
$query1 = "從測試中選擇 foo";
$query2 = "從 bookinfo 中選擇標題、authorFirst、authorLast";
echo "查詢測驗
n";
$users = mysql_query($query1, $connection1) 或 die(mysql_error());
echo "查詢圖書
n";
$books = mysql_query($query2, $connection2) 或 die(mysql_error());
echo "Foos from test
n";
while (list($foo) = mysql_fetch_row($users)){
echo $foo, "
n";
}
echo "techbizbookguide 中的書
n";
while (list($title, $authorFirst, $authorLast) = mysql_fetch_row($books)){
//如果我們有「Madonna」或「PRince」的書或...
,請使用修剪
echo $title, ' by ', trim($authorFirst . ' ' . $authorLast), "
n";
}
? >
正文>