Jump to content

Code Help


Bob Norris

Recommended Posts

Hi,

 

New to PHP but could anybody help me adjust this code so the first search result opens in a new window? Right now the script opens a list of matches within itself but I really need it to open just the first match. Id be willing to provide a free subscription to our service if someone can help.

 

Thanks a bunch!

 

search.php:

 

http://rafb.net/p/V4WzTf41.html

Link to comment
Share on other sites

in order to get your script to open in new window change this line

 

$navigation .= "    <a href=\"" .
        	                            htmlentities(preg_replace('/&p=\d*/','',$_SERVER['REQUEST_URI'])) .
        	                            "&p=$i\">$i</a> \n";

 

 

to this

 

$navigation .= "    <a href=\"" .
        	                            htmlentities(preg_replace('/&p=\d*/','',$_SERVER['REQUEST_URI'])) .
        	                            "&p=$i\" target='_blank'>$i</a> \n";

 

notice i've add a 'target' attribute to the link..with the value of '_blank'

 

this tells the browser that we want this open on a new window.

Link to comment
Share on other sites

oops that code is for the NEXT and previous buttons

 

this below is what you should change:

 

 $body .= "    <h3><a href=\"$page_result->url\">" .
                         (($page_result->title) ? $page_result->title : $page_result->url) .
                         "</a></h3>\n" .

changed:

 $body .= "    <h3><a target='_blank' href=\"$page_result->url\">" .
                         (($page_result->title) ? $page_result->title : $page_result->url) .
                         "</a></h3>\n" .

 

as far as only one result

 

try playing with this value

 

$search_flex                 = 1;

 

keep incrementing until only one result gets returned

 

did you purchase this script?

Link to comment
Share on other sites

oops that code is for the NEXT and previous buttons

 

this below is what you should change:

 

 $body .= "    <h3><a href=\"$page_result->url\">" .
                          (($page_result->title) ? $page_result->title : $page_result->url) .
                          "</a></h3>\n" .

changed:

 $body .= "    <h3><a target='_blank' href=\"$page_result->url\">" .
                          (($page_result->title) ? $page_result->title : $page_result->url) .
                          "</a></h3>\n" .

 

as far as only one result

 

try playing with this value

 

$search_flex                 = 1;

 

keep incrementing until only one result gets returned

 

did you purchase this script?

 

Hi,

 

Thank you I will try it. If it does what I need I will purchace it. I have some of their other software and its pretty good. If this works do you want a free site chatter for your website? www.sitechatters.com  (NOT AN ADVERTIZMENT)

Link to comment
Share on other sites

Hi,

 

I circumvent the flash screen and just use the url like this: http://www.sitechatters.com/search.php?q=Joan

 

It returns several results depending on the search term ( search.php?=whatever )

 

My AI can do a website search depending on the users input IE: "Search for joan"  The then open the new window containing the query. I want that window to be the first result of the search page results

Link to comment
Share on other sites

when i did a search only one search result was returned.. out of 2 possible

 

Yes so,, I want it to go to the actually first result page.

 

If you search Joan it returns first the Softwares page (because I have not bought it yet) and another about Joan. So if it did what I want it would open their page as its first in the results.

Link to comment
Share on other sites

i don't know how you will get the address to JS from your flash but..

 

basically i guess you could use the $_GET method and attach

 

?link=address

then in php say 

if(isset($_GET['link']))
{
 $link=$_GET['link'];
}

 

//then to put it in the JS

<?php
echo("
<script>

window.open.location.href=' ".$link." ';

</script>
");
?>

something like that..

 

 

Link to comment
Share on other sites

i don't know how you will get the address to JS from your flash but..

 

basically i guess you could use the $_GET method and attach

 

?link=address

then in php say 

if(isset($_GET['link']))
{
  $link=$_GET['link'];
}

 

//then to put it in the JS

<?php
echo("
<script>

window.open.location.href=' ".$link." ';

</script>
");
?>

something like that..

 

 

 

Everything is done through the search.php The flash is just a form that I wont use

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.