Hello Experts !!!
I have two databases to select from my web page. In this script i can search one database(if ($choice=="staff publication") it works. I dont know how to write the script if I select the other option if($choice=="books"). Please can any one help me. I want to display search resuls of "books" the same way as staff publications. but books database has different fields.
if($choice=="books"){
$query="SELECT * FROM books WHERE match (authors, title, callnumber keywords, edition, year, notes) against ('$name' in boolean mode) ORDER BY year DESC";
}
I want to put the above somewhere in the script and display results.
<?php
$link = mysql_connect('localhost', 'root', 'vip');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('test1');
@mysql_select_db(test1) or die("unable to connect");
$choice=$_POST['choice'];
$name=$_POST['name'];
if ($choice=="staff publications"){
$query="SELECT * FROM staffpub WHERE match (authors, title, source, keywords, mesh, year, notes) against ('$name' in boolean mode) ORDER BY year DESC";
}
$result=mysql_db_query("test1", $query);
$num_rows = mysql_num_rows($result);
if ($num_rows==0){$search_result="<p class='error'>No Results Found</p>";}
elseif ($num_rows > 0){$search_result="<p class='error'>".$num_rows. " Results Found</p>";}
mysql_close();
echo '<b><center><font size="4" color="#FF0000">Search Result</font></center></b><br><br>';
$i=0;
while ($i < $num_rows) {
$authors=mysql_result($result,$i,"authors");
$title=mysql_result($result,$i,"title");
$source=mysql_result($result,$i,"source");
echo "<b>Authors:</b> $authors<br><b>Title:</b> $title<br><b>Source:</b> $source<br><br><hr><br>";
$i++;
?>