0
我有2個搜索表單。一個鏈接到我本地的記錄數據庫,另一個通過API鏈接到另一個數據庫。合併搜索表格
我想現在當我的數據庫沒有所需的記錄,讓它使用第二個搜索表單,用戶不需要再次插入數據。
這是可能的,我該如何去合併兩者?
感謝所有的幫助傢伙。
的形式的功能結合:
<div class="article">
<h2>
<br>
SEARCH A REFERENCE
<br>
</h2>
</center>
<body>
<div id="formsearch">
<br>
<form method="post" action="" name="form1" id="form1" >
Enter the ID Number
<br><br>
<b>Search Record </b> <input type="text" name="term" /><br />
<br>
<input type="submit" name="submit" value="Search" class="btn" />
</form>
</div>
<h3> <center> Search Result (s) </h3>
<?php
if ($_REQUEST['submit']) {
$term = $_POST['term'];
$row ['employerid'] == $user_data ['user_id'];
$XX = "<br><br><div class='messagebox'><h2> <center> Oops! </h2> <p>We were only to retrieve a partial record on <strong>$term</strong> you have entered. Please make use of our contact form if you would like us to get you your reference. Be sure to enter the three required fields. <a href='Mailforms/refrequest.php' class='lightbox'>Click Here!</a> or to validate the id <a href='idverification.php'> Click here</a></p>
<br />
</div>";
$sql = mysql_query("SELECT idnumber,
firstname,
lastname,
companyname,
jobtitle,
dismissal,
terminationdate,
startdate,
CONCAT(TIMESTAMPDIFF(YEAR,startdate,terminationdate), ' years and ',
MOD(TIMESTAMPDIFF(MONTH,startdate,terminationdate),12), ' months ') AS time_diff
FROM ref_employees
WHERE idnumber= '$term'")
or die('Error in query : $sql. ' .mysql_error());
if (mysql_num_rows($sql) > 0 ) {
while ($row = mysql_fetch_array($sql)){
if ($row ['employed'] == '1') {
echo '<h4>Currently Employed By : '.$row['companyname'];
echo '</h4> ';
echo '<a href="#">Any doubts? Enquire about this candidate</a> ';
}
if ($row ['employed'] == '0') {
echo ' <h4>Some Available Options For:</h4>';
include 'includes/admenu.php';
echo '<h4>Not Currently employed '.$row['companyname'];
echo '</h4> ';
}
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID Number</th> <th>First Name</th> <th>Last Name</th><th>company</th> <th>Job Title</th> <th>Period</th><th>Reason for dismissal</th><th></th><th></th></tr>";
echo "<tr>";
echo '<td>' . $row['idnumber'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td>' . $row['companyname'] . '</td>';
echo '<td>' . $row['jobtitle'] . '</td>';
echo '<td>' .($row['startdate'] + $row['terminationdate']).'</td>';
echo '<td>' . $row['dismissal'] . '</td>';
echo '<td><a href="editemp.php?idnumber=' . $row['idnumber'] . '">Achievements</a></td>';
echo '<td><a href="delete.php?idnumber=' . $row['idnumber'] . '">training</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
}
}
else
{
$id_number = $_POST['term'];
$authenticate = authentication();
$login_message = $authenticate['error_code'];
$session_id = $authenticate['session_id'];
$id_verification = verify_id($session_id, $id_number);
}
if (!empty($id_verification)){
echo '<br/>';
echo '<h3>Search Information</h3>';
echo 'Time Stamp: ';
echo $id_verification['TIME_STAMP'];
echo 'SOAP Result: ';
echo $id_verification['LOGIN-MESSAGE'];
echo ' ';
echo $id_verification['SEARCH-MESSAGE'];
echo ' ';
echo $id_verification['SEARCH-RESULT'];
echo '<br/>';
echo '<h3>Data: </h3>';
echo '<br/>ID Number: ';
echo $id_verification['IDNUMBER'];
echo '<br/>First Names: ';
echo $id_verification['FIRSTNAMES'];
echo '<br/>Last Name: ';
echo $id_verification['SURNAME'];
echo '<br/>Birthday: ';
echo $id_verification['BIRTHDAY'];
echo '<br/>Age: ';
echo $id_verification['AGE'];
echo '<br/>Gender: ';
echo $id_verification['GENDER'];
echo '<br/>Citizen: ';
echo $id_verification['CITIZEN'];
echo '<br/>Death Status: ';
echo $id_verification['DEATH-STATUS'];
echo '<br/>Death Date: ';
echo $id_verification['DEATH-DATE'];
echo '<br/>Death Place: ';
echo $id_verification['DEATH-PLACE'];
unset($_SESSION['id_verification']);
}
mysql_free_result($sql);
mysql_close($connection);
?>
我提供了代碼 –
在您的本地搜索表單中,您正在檢查'if(mysql_num_rows($ sql)> 0){'中的結果數量。我會建議放一個else語句並執行API搜索。 'if(mysql_num_rows($ sql)> 0){/ *本地搜索到這裏* /} else {/ *把api搜索放在這裏* /}'實際上這就是Nesarajan所建議的。 – secelite
我結合了2但沒有運氣。請我真的apreciat你援助這個,我是新來的PHP。 –