Bob Norris Posted July 18, 2008 Share Posted July 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 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) Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 sure that would be kwl Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 Hey, Didnt work, came up blank http://www.sitechatters.com/search.php Use serach term Joan Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 18, 2008 Share Posted July 18, 2008 What? Joan returned items for me, what is supposed to happen? Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 What? Joan returned items for me, what is supposed to happen? Hi, I changed back the script without the target. I want it to open just the first result in a window Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 18, 2008 Share Posted July 18, 2008 Automatically? You could use javascripts window.open to do this. Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 when i did a search only one search result was returned.. out of 2 possible Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 ic.. ok.. well you'll need to you javascript for that I blieve.. you'll need to pick up that address returned by the search and use js to auto open a window.. to that address (Lunch Time-whoowhoo)brb1hr Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 ic.. ok.. well you'll need to you javascript for that I blieve.. you'll need to pick up that address returned by the search and use js to auto open a window.. to that address (Lunch Time-whoowhoo)brb1hr Ok, Any ideas? Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 Anybody? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 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.. Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 well the same still applies.. only difference is you might be able to use _POST but _GET will work just fine. Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 So, me not being a coder,, where would I put all this? Quote Link to comment Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 something like this would have to wait until I got home from work.. :-\ Quote Link to comment Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 No problem, For some reason Im not getting notifid of replies here. Email me when you have time. Im on yahoo, aol, msn, irc, icq too Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.