Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

using javascript for php search?!?

Javascript coding ..

Moderators: macek, egami, gesf

using javascript for php search?!?

Postby ericehle » Thu Jan 23, 2003 10:52 pm

I was looking at http://www.designiskinky.com , and I was trying to create a search similar to what they did on their news search, althought I am not able to use mysql on my webserver(so I am told but can use php). Any info on how they did this or what steps to take to head in the right direction is more than appreciated. The source code is below but not sure what it is exactly doing and how to make it work for me. Any suggestions are more than appreciated.
Thanks,
Eric Ehle

<script language="javascript" type="text/javascript">
function pageSearch(iVal) {
document.forms[0].currPage.value = iVal;
document.forms[0].submit();
}
</script>

<form action="news-search.php" method="post" name="dik_search">
ericehle
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 23, 2003 10:47 pm

Postby icu90ucme » Thu Aug 07, 2003 7:26 pm

this doesn't have any javascript at all but it might help you
this is just a generic search
Code: Select all

// this will be your original search page
  <form action="search_results.php" method="post">
<table width="100%" cellspacing='1'>
  <tr>
   <td>Choose Search Type:<br /></td>
   <td><select name="searchtype" id='dropdown'>
        <option value="option">Option 1</option>
        <option>Option 2</option>
        <option>Option 3</option>
        </select>
  </tr>
  <tr>
   <td>Enter Search Term:<br /></td>
   <td><input name="searchterm" type="text" id='textinput' size="20"></td>
</table>
    <input type="submit" value="Search">
  </form>


and then this is the results page
Code: Select all
  // create short variable names
  $searchtype=$HTTP_POST_VARS['searchtype'];
  $searchterm=$HTTP_POST_VARS['searchterm'];

  // then connect to database and query
  $dbconnect = connection to database
  $query = "select * from table where ".$searchtype." like '%".$searchterm."%'";
  $result = mysql_query($query);

  // see how many hits you got
  $num_results = mysql_num_rows($result);

echo 'Number of entries found: '.$num_results.';

  // show results of search by creating a loop
  for ($i=0; $i <$num_results; $i++)
  {
   $row = mysql_fetch_array($result);

  // put results in a table
  <table width='100%' cellspacing='1'>
  <tr><td>
echo stripslashes($row['entry']);
   </td></tr>
   </table>

 


again this is just generic code but it should be able to get you started in the right direction and throw some ideas in your head
icu90ucme
New php-forum User
New php-forum User
 
Posts: 23
Joined: Mon Jul 07, 2003 2:29 pm

Postby swirlee » Thu Aug 07, 2003 7:54 pm

The JavaScript you posted doesn't do any actual searching, or much at all, even. There's no decent way to search a site with JavaScript, and MySQL isn't necessarily the way to go. If you're looking for a PHP solution, there are plenty to be Googled. One I just found that looks promising is PHPSiteSearch, which stores the search database in a text file. But I don't know how good it is. There are plenty of PHP search engines to be found at HotScripts, some of which utilize MySQL and some of which do not.

If none of those are what you're looking for, consider using Google's Site Search. The downside is that the search results appear at Google's site, not yours, but the upside is that Google produces damned good search results.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

MySQL Way

Postby ruturajv » Sun Aug 10, 2003 10:50 pm

An easy way to do it with MySQL is
    [list=]Create a table for search keywords
    [list=]Then populate the table with keywords, and the corresponding hyperlink
on the search page query the keywords and display the corresponding page
[/list]
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Re: using javascript for php search?!?

Postby swirlee » Mon Aug 11, 2003 6:14 am

ruturajv wrote:An easy way to do it with MySQL is ...


ericehle wrote:... althought I am not able to use mysql on my webserver ...
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.