phpMyAdmin Search made simple

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shantanuo
Forum Newbie
Posts: 1
Joined: Sun Oct 20, 2002 12:32 am

phpMyAdmin Search made simple

Post by shantanuo »

Everyone of us has used the firefox search box at the top right corner to search. If you click on the drop down box you can see the other options. You can create your own database search plugin. You will choose the database name from the search drop down and type the word you want to search!

Here are two files (form.htm and create.php) you need to upload to your (PHP supported) server. Type the path to your "db_search.php" file and the database name. When you submit this information, you will have to click on the install link on the next page. Now select the newly created plugin and type any word you want to search within your database.


form.htm

Code: Select all

<html>
<body>
<h2>Create Search Plugin for Firefox</h2>
<b>If you are using phpMyAdmin, type the details of your phpMyAdmin path and database name...</b><p>
<FORM name=&quote;myform&quote; ACTION=&quote;create.php&quote; METHOD=&quote;POST&quote;>
Search plugin Name:<INPUT TYPE=&quote;TEXT&quote; NAME=&quote;qname&quote; value=&quote;bookmarks&quote;><p>
<SUP>*</SUP>Database ID:<INPUT TYPE=&quote;TEXT&quote; SIZE=55 NAME=&quote;databaseID&quote; value=&quote;http://saraswaticlasses.com/phpMyAdmin/db_search.php&quote;><p>
Database Name:<INPUT TYPE=&quote;TEXT&quote; NAME=&quote;dname&quote; value=&quote;private&quote;><p>
<INPUT TYPE=&quote;SUBMIT&quote; VALUE=&quote;create file&quote; NAME=&quote;sendit&quote;>
</form><p>
<SUP>*</SUP>The path to the &quote;db_search.php&quote; file within your phpMyAdmin installation.

</body>
</html>
create.php

Code: Select all

<html>
<head>

<script type="text/javascript">
<!--
function errorMsg()
{
 alert("Netscape 6 or Mozilla is needed to install this plugin");
}
function addEngine(<?php echo $qname ?>,ext,cat)
{
 if ((typeof window.sidebar == "object") && (typeof
 window.sidebar.addSearchEngine == "function"))
 {
   //cat="Web";
   //cat=prompt('In what category should this engine be installed?','Web')
   window.sidebar.addSearchEngine(
     "http://saraswaticlasses.com/download/plugin/"+<?php echo $qname ?>+".src",
     "http://saraswaticlasses.com/download/plugin/"+<?php echo $qname ?>+"."+ext,
     name,
     cat );
 }
 else
 {
   errorMsg();
 }
}
//-->
</script>

</head>
<body>

<?php
$file = fopen($qname.'.src','w');

$my_stuff = <<<END
<search name="$qname" 
description="Quickbase Search" 
method="GET"
action="$databaseID">
<input name="search_option" value="1">
<input name="submit_search" value="Go">
<input name="db" value="$dname">
<input name="search_str" user>

</search>
END;

fwrite($file, $my_stuff);
fclose($file);
?> 

<a href="javascript:addEngine('<?php echo $qname; ?>','gif','Web')">Install Plugin</a><p>
Please wait....
</body>
</html>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

is this a code snippet or a question?

if the former, consider posting in the `Code Snippets` forum.
Post Reply