$tableArray = array('tbl_course','tbl_faculty');
if(!empty($_POST["searchField"]))
{
$search=$_POST["searchField"];
foreach( $tableArray as $tblArry)
{
$out .= $tblArry.";";
$sql_search = "select * from ".$tblArry." where ";
$sql_search_fields = Array();
$sql2 = "SHOW COLUMNS FROM ".$tblArry;
$rs2 =mysql_query($sql2);
if(mysql_num_rows($rs2)>0){
while($r2 = mysql_fetch_array($rs2)){
$colum = $r2[0];
$sql_search_fields[] = $colum." like('%".$search."%')";
}
}
$sql_search .= implode(" OR ", $sql_search_fields);
$rs3 = mysql_query($sql_search);
}
}
问题是我想显示数据库的结果。该脚本循环遍历2个表的列,并基于该表创建一个SQL语句。
我面临的唯一问题是如何从结果集r3中获取数据?