•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,685 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1401 | Replies: 2
![]() |
•
•
Join Date: Apr 2005
Posts: 15
Reputation:
Rep Power: 4
Solved Threads: 0
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++;
?>
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++;
?>
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation:
Rep Power: 4
Solved Threads: 1
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
adsense adult advertising blog blogging bomb book business coding competition copyright daniweb development earth engine environment failure forum gentoo google internet legal linux malware marketing mcafee microsoft monetization msn news operating pagerank phishing php privacy publishing revenue search security silverlight software spam spyware support system technical web webmaster wiki yahoo
- unlicenced use of gif images (Web Developers' Lounge)
- SQL search query (PHP)
- Getting out of the Sandbox (Search Engine Optimization)
- I search for the good remote work! (Software Development Job Offers)
- Can we access Databases through C or C++ (C++)
- Subfolder Search Loop (Visual Basic 4 / 5 / 6)
- Search two tables (PHP)
- more "home search assistent" fun... (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: a problem with setcookie
- Next Thread: PHP Server-Side Hit Counter for Beginner


Linear Mode