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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/ 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. Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593500 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? Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593506 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) Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593542 Share on other sites More sharing options...
ag3nt42 Posted July 18, 2008 Share Posted July 18, 2008 sure that would be kwl Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593551 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593552 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? Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593567 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593568 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. Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593570 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593575 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593578 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. Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593581 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593585 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? Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593587 Share on other sites More sharing options...
Bob Norris Posted July 18, 2008 Author Share Posted July 18, 2008 Anybody? Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593633 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.. Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593681 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593688 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. Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593696 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? Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593712 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.. :-\ Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593767 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 Link to comment https://forums.phpfreaks.com/topic/115443-code-help/#findComment-593770 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.