以下脚本成功地允许我搜索日期并在“JOBS”表中显示与时间相关的所有信息,这些信息已放在存储在“orderno”表中的系统上。
// PUT your connection data HERE !
$DB_SERVER = 'localhost';
$DB_NAME = 'database';
$DB_USER = 'username';
$DB_PASS = '*********';
// opening a connection to the database
try
{
$db = new PDO("mysql:host=".$DB_SERVER.";dbname=".$DB_NAME.";charset=utf8", $DB_USER, $DB_PASS, array(PDO::ERRMODE_EXCEPTION, PDO::FETCH_ASSOC) );
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$sql =
"SELECT o.JobNumber, o.date_col, Job_Title, Handler
FROM orderno o
INNER JOIN JOBS j on (o.JobNumber = j.JobNo)
WHERE date_col = ?";
// preparing the query
$stmt = $db->prepare($sql);
// assembling the requested date
$date = $_GET['year'] . '-' . $_GET['month'] . '-' . $_GET['day'];
// setting the parameter value
$stmt->bindParam(1, $date, PDO::PARAM_STR);
// executing the query
$stmt->execute();
// returning the resultset
$resultSet = $stmt->fetchAll();
if ( count($resultSet) == 0 ) {
echo "No records found for date ".$date;
}
else {
echo '<table border=1>';
// writing the table header
echo '<tr>';
foreach($resultSet[0] as $key => $value) {
if (!is_numeric($key)) {
echo '<TH>'.$key.'</TH>';
}
}
echo '</tr>';
// writing the rows...
foreach($resultSet as $row) {
echo '<tr>';
// each field...
for($i = 0; $i < $stmt->columnCount(); $i++) {
echo '<td>'.$row[$i].'</td>';
}
echo '</tr>';
}
echo '</table>';
}
?></center>
但是,在“JOBS”表中,“处理程序”存储为数字。在“处理程序”表中,它显示相关编号,但将其与全名匹配。
如何将此脚本链接到“处理程序表”并在此列中显示 FullName 而不是存储在 JOBS 表中的数字?
谢谢!