$res = mysql_query("select s1.*, s2.* from s1,s2");
$A = array();
$B = array();
while($arr = mysql_fetch_array($res))
{
for(i=0;i<count($arr)/2;i++)
{
$A[][$i] = $arr[$i];
}
for(j=count($arr)/2;j<count($arr);i++)
{
$B[][$j] = $arr[$j];
}
}
不知道这样行不
$A = array();
$B = array();
while($arr = mysql_fetch_array($res))
{
for(i=0;i<count($arr)/2;i++)
{
$A[][$i] = $arr[$i];
}
for(j=count($arr)/2;j<count($arr);i++)
{
$B[][$j] = $arr[$j];
}
}
不知道这样行不
是不可以的,这样可到的结果记录数是两表记录数的笛卡儿乘积,显然不符合题义既然两表字段完全相同,读取数据时可用一个字定义函数。其实不相同也一样的function get_recn($result_ori) {
for ( $temp_x = 0 ; $temp_x < $rows_ori ; $temp_x++)
{
$ori_row = mysql_fetch_array($result_ori);
$fieldname_ori = mysql_field_name($result_ori,0);
for ( $temp_y = 0 ; $temp_y < $cols_ori ; $temp_y++ )
{
$fieldname_ori = mysql_field_name( $result_ori,$temp_y );
$b[$temp_x + 1][$temp_y + 1] = (int) $ori_row[$fieldname_ori] ;
}
}
return $b;
}$result_ori = mysql_query("select * from s1");$cols_ori = mysql_num_fields($result_ori);
$rows_ori = mysql_num_rows($result_ori);
$a = get_recn($result_ori);
$result_ori = mysql_query("select * from s2");
$b = get_recn($result_ori);mysql_free_result($result_ori);
简单的说就是两表的记录数的乘积
设a表4条记录,b表3条记录
则select * from a,b
得到12条记录
s1->a[1][1]
s2->b[1][1]
s1->a[1][2]
s2->b[1][2]
……
s1->a[2][1]
s2->b[2][1]
……
s1->a[m][n]
s2->b[m][n]
end