PHP - How To Show The Suggestion Text According To Prefix
Hi,
<?php $xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName('link'); //get the q parameter from URL $q=$_GET["q"]; //lookup all links from the xml file if length of q>0 if (strlen($q)>0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } } } // Set output to "no suggestion" if no hint was found // or to the correct values if ($hint=="") { $response="no suggestion"; } else { $response=$hint; } //output the response echo $response; ?>
Similar TutorialsHi all. I'm working on a PHP application that will serve several clients. After a discussion on another thread about compliance, I've decided that using tables with a client specific prefix would be the safest way to go. However, I'm having a lot of trouble wrapping my head around what the database connection script would look like. I have a generic one that connects with host, user, pwd, and db as arguments but I'm not sure how to modify it to incorporate the table prefix requirement. Thoughts on how I can incorporate the aforementioned requirement and enhance the script in general? function connect_mysql($host,$user,$pass,$database){ $conn=mysql_connect($host,$user,$pass)or die('Cannot create link'); mysql_select_db($database)or die('Cannot select database'); }; hey guys trying to find out what the short name of FireFox2 is. (for example the "IE 6" in this code) What would it be for firefox versions 2? Code: [Select] <!--[if IE 6]> <meta http-equiv="refresh" content="0; url=http://example.com/"> <![endif]--> THANKS!!! This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=342336.0 ok, I am hoping the code is self explanatory... but if not, I'm creating a script which I will be using for something else. Basically it says if OS and browser show code under... I am looking for two things. 1. Is there a way to make it so that it can pull from a list and show that if HTTP_USER_AGENT comes back with a specific output, to say you are using X OS with Y browser? 2. The last bit, it is meant to say, if not any of the options show the info below. For some reason it's not doing that... can someone please tell me why? Thanks. Code: [Select] <?php //Operating Systems function xp(){return(eregi("Windows NT 5.1", $_SERVER['HTTP_USER_AGENT']));} function vista(){return(eregi("Windows NT 6.0", $_SERVER['HTTP_USER_AGENT']));} function win7(){return(eregi("Windows NT 6.1", $_SERVER['HTTP_USER_AGENT']));} function ubuntu(){return(eregi("Ubuntu/", $_SERVER['HTTP_USER_AGENT']));} //Web Browsers function chrome(){ return(eregi("Chrome/", $_SERVER['HTTP_USER_AGENT']));} function safari(){ return(eregi("Safari/", $_SERVER['HTTP_USER_AGENT']));} function firefox(){ return(eregi("Firefox/", $_SERVER['HTTP_USER_AGENT']));} function ie9(){ return(eregi("MSIE 9.0", $_SERVER['HTTP_USER_AGENT']));} function ie8(){ return(eregi("MSIE 8.0", $_SERVER['HTTP_USER_AGENT']));} // do something if XP and Chrome if(xp() && chrome()){echo 'You are using Windows XP with a Chrome web Browser';} // do something if XP and IE8 if(xp() && ie8()){echo 'You are using Windows XP with a Internet Explorer 8 web Browser';} // do something if Windows 7 and IE9 if(win7() && ie9()){echo 'You are using Windows 7 with a Internet Explorer 9 web Browser';} // do something if Windows Vista and IE9 if(vista() && ie9()){echo 'You are using Windows Vista with a Internet Explorer 9 web Browser';} // do something if Windows Vista and IE8 if(vista() && ie8()){echo 'You are using Windows Vista with a Internet Explorer 8 web Browser';} // do something if Ubuntu and Firefox if(ubuntu() && firefox()){echo 'You are using Ubuntu with a Firefox web Browser';} if(!ubuntu() || !xp() || !vista() || !win7() || !firefox() || !chrome() || !safari() || !ie9() || !ie8()){ echo'<strong>'; echo '<br />' . $_SERVER['HTTP_USER_AGENT'] . '<br /><br />Administrator someone in your work force is using an unsupported browser/OS combination, please email the information above to the developer of the NCMR software you are using. It will allow your browser/OS combination to be used correctly. Sorry for the inconvenience.</strong> <br /><br />Please copy and paste the text above and send it to your web administrator. It will explain everything he/she needs to do.';} ?> Hi, I want to show part of the text from a page containing my article on my main page. The article resides in a database in mysql. How do I limit the amount of text that is shown without setting up a separate excerpt box for the article. I want to then provide a link so the user can go to another page that displays the entire article. Thanks for any suggestions. Hi All, I am fairly new to PHP. I want to write some code that will get content from specific classes that are in a HTML page. I.e. <p>text 1</p> <p class="description">text2</p> <p>text3</p> I want to just output text where class = description. How would i do this? Hi there, Im working on my little project and I would appreciate your help. I have only basic knowledge of php, mostly I just copy some scripts that could be useful for me. Im trying to find some simple script that allows me to see the written text on web page no. 1 on webpage no. 2.. Something like send the form to email, except I dont want to send it on email, but different webpage. Something like different way of eshop, where you get your order shipped to email, but I wanna send this information to webpage. Is there such a script like Im describing? Probably is but I dont know how to search for this..
Thank You
Edited by Radim, 21 October 2014 - 07:15 AM. Hi Guys, I wonder if you can help me before I go crazy? I have the task of updating a site by adding text to every page, at the moment there are three pages on the live website that show both images and text, I am to update the remaining 6 with text to go with the images.... I thought this was all fine and dandy, added the text in, checked the code, uploaded to the FTP site and nothing, only 1 page worked. I am stuck as I have used the same method to add text to all the pages yet those elusive pages refuse to show text! This is driving me crazy and i am hoping that one of you guys has come across this before and will be able to highlight a missing piece of code or have a solution? I do appreciate your time and any suggestions that you have. I have attached the page below. Thanks guys! It would be cool if when you hover over someone's thread a brief popup window appears showing a snippet of what is inside so a person can easily decide whether or not to click on a thread, I realize that could lower the potential "clicks" which in turn would lower the potential revenue from ads but...
It would be cool if when you hover over someone's thread a brief popup window appears showing a snippet of what is inside so a person can easily decide whether or not to click on a thread, I realize that could lower the potential "clicks" which in turn would lower the potential revenue from ads but...
Hello, i Want the following code and the Variable $page To load a file in a folder. And get all of its contents. How would i do this? <?php $page = "{$_GET['page']}"; if(md5($_GET['page'] == '')) { } ?> I have a need to create a form that will get info from a mysql table, show that info, two fields one of which I want to be a checkbox that will need to update the table with either a 0 or a 1. I will later use that info. I have searched all over and haven't found what I am looking for. I can find tutorials for creating checkboxes but nothing what I need / want
Hi guys
I am a php programmer and in a big confusion. I want to learn a framework, but can't figure out which one start ?
CakePHP
Codelgniter
Symfony
laravel
I am new to them, so you can suggest me which one to start 1st and move on to other. Or If i miss any other framework , you can tell me that also.
Any help is appriciable.
Thanks
HI I need to make a website or app like https://app.echosec.net/ or http://geofeedia.com/ Can someone guide what I need to do to make it like this? I tried using map and getting coordinates from selected area but unable to get exactly what I need to do later? Thanks in adv. What type of project that can be. It won't be a pesonal website. It would be a database oriented website. Hello, Please can someone tell me how to create a form field suggestion box (like to box of suggestions that appears under the google search bar)? Many thanks, Stu i need to load advertisemtn and after that video. how it is possible to do example link is belove. i need to load random commercials on random vidoes. please guide me thanks http://sports.yahoo.com/nfl/blog/shutdown_corner/post/Enjoy-special-teams-failures-Merry-Christmas-fr?urn=nfl-295573 Here is my simple script for user browser and OS detection: $agent = $_SERVER['HTTP_USER_AGENT']; if (strstr($agent,"Windows")) {$os = "Windows";} if (strstr($agent,"Windows NT 6")) {$os = "Windows 7";} if (strstr($agent,"Linux")) {$os = "Linux";} if (strstr($agent,"Intel Mac OS X")) {$os = "OS X";} if (strstr($agent,"OpenBSD")) {$os = "BSD";} if (strstr($agent,"FreeBSD")) {$os = "FreeBSD";} if (strstr($agent,"Firefox/3")) {$br = "Firefox 3";} if (strstr($agent,"Firefox/2")) {$br = "Firefox 2";} if (strstr($agent,"Firefox/1")) {$br = "Firefox 1";} if (strstr($agent,"Phoenix/")) {$br = "Phoenix (Mozilla lite)";} if (strstr($agent,"MSIE 6")) {$br = "IE 6";} if (strstr($agent,"MSIE 7")) {$br = "IE 7";} if (strstr($agent,"MSIE 8")) {$br = "IE 8";} if (strstr($agent,"Netscape6/6")) {$br = "Netscape 6";} if (strstr($agent,"Opera")) {$br = "Opera";} if (strstr($agent,"Opera") and strstr($agent,"Version/10")) {$br = "Opera 10";} if (strstr($agent,"Opera") and strstr($agent,"Version/9")) {$br = "Opera 9";} if (strstr($agent,"Chrome") and strstr($agent,"Chrome/5")) {$br = "Chrome 5";} if (strstr($agent,"Safari/")) {$br = "Safari";} if (strstr($agent,"Safari/") and strstr($agent,"Version/5")) {$br = "Safari 5";} if (strstr($agent,"Safari/") and strstr($agent,"Version/4")) {$br = "Safari 4";} if (strstr($agent,"Safari/") and strstr($agent,"Version/3")) {$br = "Safari 3";} if (strstr($agent,"SeaMonkey/") and strstr($agent,"Gecko")) {$br = "SeaMonkey";} echo "Browser: <b>$br</b>, OS: <b>$os</b>"; I found some information from he http://www.zytrax.com/tech/web/browser_ids.htm Is there any better solution for this, or script above is accurate? I have a function that's supposed to search through my user database and find the member the query was searching for. Is there a way to make it so that it suggests users while I'm typing? I have my own shopping cart system, where I add to my cart by clicking an INPUT element inside a form, which posts a hidden INPUT value to a processing page that PHP uses to add the item the PHP session, and then I click "OK" which just JavaScript backs 1 page. I find this flow a little cheap, and wondering if its possible to use another way to add an item to a PHP session with out having to leave the page? JavaScript maybe? Can anyone suggest a solution? Unfortunately this desire exceeds my engineering knowledge. |