Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-30-2010, 03:44 AM search help
Average Talker

Posts: 21
Name: Mike
Trades: 0
all files are php .... Website with the search box in the main site and the search engine is the iframe site

This is the code for the top of the website search box

<input name="search" class="search" type="text" value="under construction..." onfocus="if(this.value == 'under construction...'){this.value = '';}"/>

The search engine is on the website in iframe

code:

<p><iframe src ="http://testsite2.comze.com/test/search" width="100%" height="580" frameBorder="0">
<p>Your browser does not support iframes.</p>
</iframe></p>

The form code in the http://testsite2.comze.com/test/search/index.phpfor the iframe

<form action='index.php' method='get'>
<center><h2>Search</h2><br />

<input type='text' name='query' size='50' value='<?php echo $query; ?>' />
<br />
<input type='submit' value='Search!' />
</center>
</form>

How can i get to where someone types in the top search box and the results show in the results page from the search engine in iframe

Image:


Last edited by mercville; 03-31-2010 at 07:20 AM..
mercville is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-31-2010, 06:00 AM Re: search help
Super Talker

Posts: 139
Name: John Davis
Trades: 0
You can use Ajax instead of iframe. It easiest way, imho.

In any way, you also can get any data from iframe using DOM.
document.getElementById('iframe_id').document.<any parameter like in usual page>
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
Reply With Quote
View Public Profile Visit MapMaster's homepage!
 
Old 03-31-2010, 07:32 AM Re: search help
Average Talker

Posts: 21
Name: Mike
Trades: 0
i'm lost sorry so how would i do that
mercville is offline
Reply With Quote
View Public Profile
 
Old 03-31-2010, 12:08 PM Re: search help
Andy Pugh's Avatar
Extreme Talker

Posts: 203
Name: Andy
Location: N.Ireland
Trades: 0
As a simple solution, simply add a target to your search function, ensure you give your iframe an ID.

PHP Code:
<p><iframe id="myiframe" src=http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.webmaster-talk.com/"http://testsite2.comze.com/test/search" width="100%" height="580" frameBorder="0">
<p>Your browser does not support iframes.</p>
</
iframe></p
Then on your search function

PHP Code:

<form action="index.php" method="get" target="myiframe">
<center><h2>Search</h2><br />

<input type='text' name='query' size='50' value='<?php echo $query?>' />
<br />
<input type='submit' value='Search!' />
</center>
</form>
Should do the trick.

Cheers,
Andy
__________________

Please login or register to view this content. Registration is FREE
Andy Pugh is offline
Reply With Quote
View Public Profile
 
Old 03-31-2010, 04:25 PM Re: search help
Average Talker

Posts: 21
Name: Mike
Trades: 0
Thanks for the reply ... Works great , but how do you get the main site search box on top to show the results in the iframe search area

After typing in the search box on top right of the site and hitting enter the results show up on the main search site and not in the iframe.

Last edited by mercville; 03-31-2010 at 06:50 PM..
mercville is offline
Reply With Quote
View Public Profile
 
Old 03-31-2010, 06:47 PM Re: search help
Average Talker

Posts: 21
Name: Mike
Trades: 0
All files are php ....

I have a project to do for this company and on the main website I have to get this to work. The site layout has a search box on the top right http://testsite2.comze.com/test and they have a page called business directory http://testsite2.comze.com/test/businessdirectory.php and its iframe with this site http://testsite2.comze.com/test/search/index.php

Trying to get it to where when the users type in the search box on the top right it will show the results in the iframe of the other site business directory on the iframe middle of the main site.

When u type in "ho" and click enter it takes you to the search site and show's the results there but trying to get it to show the results in the same site but in the iframe. (only business Directory search box is working to try it)

The code for the search box on main layout is:
Code:
<form action="./search/index.php" method="get" target="myiframe">
<input name="query" class="search" type="text" value='<?php echo $query; ?>' "/>
</form>
The code for the businessdirectory.php that holds the link for the site to be iframe is:
Code:
<p><iframe id="myiframe"  src ="http://testsite2.comze.com/test/search" width="100%" height="580" frameBorder="0">
  <p>Your browser does not support iframes.</p>
</iframe></p>
This is the code for the search site thats the iframe site:
Code:
<?php
    $query = mysql_real_escape_string($_GET['query']);
    ?>
    <form action='index.php' method='get' id="myiframe">
    <center><h2>Search</h2><br />
    
    <input type='text' name='query' size='50' value='<?php echo $query; ?>' />
    <br />
    <input type='submit' value='Search!' />
    </center>
    </form>
The code for the results thats in iframe from the search site:
Code:
<?php
    


if($query != ''){
    $per_page = 10;


    $start = $_GET['start'];

    //count records
    $record_count = mysql_num_rows(mysql_query("SELECT * FROM businesses WHERE keywords LIKE '%$query%'"));
   
      if($record_count == 0){
echo "No records found";
}
    
    //count max pages
    $max_pages = $record_count / $per_page; //may come out as decimal

    if (!$start)
       $start = 0;
       
    //display data
    $get = mysql_query("SELECT * FROM businesses WHERE keywords LIKE '%$query%' LIMIT $start, $per_page");
    while ($row = mysql_fetch_assoc($get))
    {
     // get data
     $name = $row['name'];
     $description = $row['description'];
     $id = $row['id'];
     
     
     echo "<b><a href='business.php?id=$id'>".$name."</a></b>";
     echo "<br />";
     echo $description;
     echo "<br /><br />";
     

    }

    //setup prev and next variables
    $prev = $start - $per_page;
    $next = $start + $per_page;

    //show prev button
    echo "<br /><br />";
    if (!($start<=0))
           echo "<a href='index.php?start=$prev&query=$query'>Prev</a> ";

    //show page numbers

    //set variable for first page
    $i=1;

    for ($x=0;$x<$record_count;$x=$x+$per_page)
    {
     if ($start!=$x)
        echo " <a href='index.php?start=$x&query=$query'>$i</a> ";
     else
        echo " <a href='index.php?start=$x&query=$query'><b>$i</b></a> ";
     $i++;
    }

    //show next button
    if (!($start>=$record_count-$per_page))
           echo " <a href='index.php?start=$next&query=$query'>Next</a>";
}
?>
mercville is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to search help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17859 seconds with 12 queries