Greetings!
I have a form that's meant to be a rudimentary search engine.
The forms calls the piece of code below and outputs successfully the results in a new tab.
<?php
//Includes the db config file
$dbconf = include '.../config/dbConfig.php';
//checks if fields are set.
if(isset($_POST['submit'])) {
if(
!empty($_POST['search_string'])
) {
searchWebcases();
searchResolutions();
} else {
echo "<html><body>
<script type=\"text/javascript\" language=\"javascript\">alert(
'Nothing to do.'
+ '\\n\\n' + ' You must type a letter, word or phrase before you can hit \"Run Search\"'
+ '.');</script> </body></html>";
}
}
function searchWebcases() {
/*
* Grabs $dbconf and declares variables.
*/
global $dbconf;
/*
* Grabs POST value.
*/
$q = $_POST['search_string'];
/*
* Connect to db.
*/
$con = mysql_connect($dbconf["host"], $dbconf["user"],$dbconf["password"]) ;
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbconf["db"], $con) or die ("Couldn't select the database.");
/*
* Search webcases.
*/
$result = mysql_query("
select
wc.caseid,
wc.request_title,
wc.request_description,
wc.requestor,
wc.created_on,
wc.status,
wc.assigned_to from webcases wc where
lower(wc.request_title) like '%".$q."%'
or
lower(wc.request_description) like '%".$q."%' order by wc.caseid asc");
/*
* build output page.
*/
$headerpage = '<html><head><title>WEBCASES matching your search criteria</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#mytable, #mytd
{
border-color: #600;
border-style: solid;
}
#mytable
{
border-width: 1px 1px 1px 1px;
border-spacing: 0;
border-collapse: collapse;
}
#mytd
{
margin: 0;
padding: 4px;
border-width: 1px 1px 0 0;
background-color: #FFC;
}
</style></head><body>';
echo $footerpage = '</body></html>';
echo $headerpage . '<table id="mytable"><thead>
<tr>
<th>ID</font></th>
<th>Title</font></th>
<th>Description</font></th>
<th>Requester</font></th>
<th>Created</font></th>
<th>Status</font></th>
<th>Developer</font></th>
</tr></font></thead><tbody>';
while($row = mysql_fetch_array($result)) {
echo("<a target='_blank'>".
'<tr><td id="mytd">'
. $row['caseid'] . '</td><td id="mytd">'
. $row['request_title'] . '</td><td id="mytd">'
. $row['request_description'] . '</td><td id="mytd">'
. $row['requestor'] . '</td><td id="mytd">'
. $row['created_on'] . '</td><td id="mytd">'
. $row['status'] . '</td><td id="mytd">'
. $row['assigned_to'] . '</td><td id="mytd">'
. '</tr>'
."</a> \n");
}
echo '</tbody></table>' . $footerpage;
mysql_close($con);
}
function searchResolutions() {
/*
* Grabs $dbconf and declares variables.
*/
global $dbconf;
/*
* Grabs POST value.
*/
$q = $_POST['search_string'];
/*
* Connect to db.
*/
$con = mysql_connect($dbconf["host"], $dbconf["user"],$dbconf["password"]) ;
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbconf["db"], $con) or die ("Couldn't select the database.");
/*
* Search webcases.
*/
$result = mysql_query("
select
wc.caseid,
wc.resolution,
wc.resolved_on from resolution wc where lower(wc.resolution) like '%".$q."%' order by wc.caseid asc");
/*
* build output page.
*/
$headerpage = '<html><head><title>RESOLUTIONS matching your search criteria</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#mytable, #mytd
{
border-color: #600;
border-style: solid;
}
#mytable
{
border-width: 1px 1px 1px 1px;
border-spacing: 0;
border-collapse: collapse;
}
#mytd
{
margin: 0;
padding: 4px;
border-width: 1px 1px 0 0;
background-color: #FFC;
}
</style></head><body>';
echo $footerpage = '</body></html>';
echo $headerpage . '<table id="mytable"><thead>
<tr>
<th>ID</font></th>
<th>Resolution</font></th>
<th>Resolved On</font></th>
</tr></font></thead><tbody>';
while($row = mysql_fetch_array($result)) {
echo("<a target='_blank'>".
'<tr><td id="mytd">'
. $row['caseid'] . '</td><td id="mytd">'
. $row['resolution'] . '</td><td id="mytd">'
. $row['resolved_on'] . '</td><td id="mytd">'
. '</tr>'
."</a> \n");
}
echo '</tbody></table>' . $footerpage;
mysql_close($con);
}
?>
Problem is that both query results display in the *same* tab i.e that of my searchWebcases() function.
Is there a way to output the results of searchResolutions() function in its own tab?