0

我想将下面两个记录集查询中的数据组合到一个 html 表中。

任何帮助将不胜感激。

亲切的问候

<?php

    if (!function_exists("GetSQLValueString")) {
        function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
        {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

            $theValue = function_exists("mysql_real_escape_string") 
                            ? mysql_real_escape_string($theValue) 
                            : mysql_escape_string($theValue);

            switch ($theType) {
            case "text":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;    
            case "long":
            case "int":
                $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                break;
            case "double":
                $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
                break;
            case "date":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "defined":
                $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                break;
            }
        return $theValue;
    }
}
//query Recordset1
$maxRows_Recordset1 = 1;
$pageNum_Recordset1 = 0;
$sourceID = $row_Users['sourceID'];


if (isset($_GET['pageNum_Recordset1'])) {
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database, $con);

$query_Recordset1 = "SELECT * FROM database1 
                        JOIN users USING (userID)
                        JOIN table1 ON table1.myID = table2.myID 
                        JOIN table4 ON table4.alias = table2.product 
                        JOIN table5 USING (table5ID) 
                     WHERE TO_DAYS(added)=TO_DAYS(NOW()) 
                        AND userID = '300' 
                        AND table5ID ='1'";

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
    $all_Recordset1 = mysql_query($query_Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
    $params = explode("&", $_SERVER['QUERY_STRING']);
    $newParams = array();
    foreach ($params as $param) {
        if (stristr($param, "pageNum_Recordset1") == false && 
            stristr($param, "totalRows_Recordset1") == false) {
            array_push($newParams, $param);
        }
    }
    if (count($newParams) != 0) {
        $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
    }
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);

//query Recordset2
$maxRows_Recordset2 = 1;
$pageNum_Recordset2 = 0;

if (isset($_GET['pageNum_Recordset2'])) {
    $pageNum_Recordset2 = $_GET['pageNum_Recordset2'];
}
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;

mysql_select_db($database, $con);
$query_Recordset2 = "SELECT * FROM database1 
                       JOIN users USING (userID)
                       JOIN table1 ON table1.myID=table2.myID 
                       JOIN table4 ON table4.alias=table2.product 
                       JOIN table5 USING (table5ID) 
                     WHERE TO_DAYS(added)=TO_DAYS(NOW()) 
                       AND userID = '300' 
                       AND table5ID='1' 
                       AND mode IN ('sent', 'success')";
$query_limit_Recordset2 = sprintf("%s LIMIT %d, %d", $query_Recordset2, $startRow_Recordset2, $maxRows_Recordset2);
$Recordset2 = mysql_query($query_limit_Recordset2, $con) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);

if (isset($_GET['totalRows_Recordset2'])) {
    $totalRows_Recordset2 = $_GET['totalRows_Recordset2'];
} else {
    $all_Recordset2 = mysql_query($query_Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($all_Recordset2);
}
$totalPages_Recordset2 = ceil($totalRows_Recordset2/$maxRows_Recordset2)-1;

$queryString_Recordset2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
    $params = explode("&", $_SERVER['QUERY_STRING']);
    $newParams = array();
    foreach ($params as $param) {
        if (stristr($param, "pageNum_Recordset2") == false && 
            stristr($param, "totalRows_Recordset2") == false) {
            array_push($newParams, $param);
        }
    }
    if (count($newParams) != 0) {
        $queryString_Recordset2 = "&" . htmlentities(implode("&", $newParams));
    }
}
$queryString_Recordset2 = sprintf("&totalRows_Recordset2=%d%s", $totalRows_Recordset2, $queryString_Recordset2);

?>
4

0 回答 0