IM表遇到了麻煩來自兩個不同的表查詢兩人在一個MySQL查詢
數據到目前爲止,我有這個
<?
include('config.php');
$xid = $_GET['xid'];
$result = mysql_query("SELECT * FROM `config`") or trigger_error(mysql_error());
while($row = mysql_fetch_array($result)){
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); }
$result = mysql_query("SELECT * FROM `utinfo` WHERE `xid` = $xid") or trigger_error(mysql_error());
while($row2 = mysql_fetch_array($result)){
foreach($row2 AS $key => $value) { $row2[$key] = stripslashes($value); }
$un = urldecode($row2['un']);
};
switch ($row['module'])
{
case 1:
echo "Function 1 for user $uid on account $un";
break;
case 2:
echo "Function 2 for user $uid on account $un";
break;
case 3:
echo "Function 3 for user $uid on account $un";
break;
default:
echo "No module defined.";
};
};
?>
的配置表的配置有行命名的模塊,它由2填充條目,其中一個是1,另外3個。所以我應該看到案例1,然後是案例3.但是,所有即時消息都是默認回顯。
在MySQL中,你可以(有時需要)在反引號(看起來像引號)括表名。 – 2009-08-01 07:46:27