PHP - Live Search Help
I'm trying to get live search set up for one of my pages and have been successful for the most part. I basically used the code provided by w3schools (http://www.w3schools.com/php/php_ajax_livesearch.asp) but need to make a modification. Their code is set up to read the link titles and urls from an xml file and search through the xml file but I would like to just search through a variable.
So in the w3schools code there is this... $xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName('link'); And I have this variable that I want it to search instead of "links.xml"... $searchTest = "<pages><link><title>Search this text</title><url>www.gohere.com</url></link></pages>"; How do I get that into the $xmlDoc variable? If I simply replace "links.xml" with $searchTest like this $xmlDoc=new DOMDocument(); $xmlDoc->load($searchTest); $x=$xmlDoc->getElementsByTagName('link'); I get nothing when I try to search. But if I create a file in the php code and write the contents of $searchTest to that file then put that file in the $xmlDoc->load("newfile.xml"); line it searches and works fine. Any ideas? Similar Tutorialsim am creating a live search using the w3schools tutorial. apart from im using mysql. here is my current code(which works fine): <?php mysql_connect("localhost", "root", ""); mysql_select_db("dictionary"); $words = mysql_query("SELECT * FROM words"); $a = array(); while ($row = mysql_fetch_assoc($words)) { $a[] = $row['word']; } $q = $_GET['q']; if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint = $hint . "</b><br /><br /> ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; } else { $response=$hint; } //output the response echo $response; ?> as you can see it is edited alot. But my problem is that i need to display underneath the word, the definition aswell. I've been trying to figure this out but i can't seem to do it. I have been trying to use multidimensional arrays. Hello sir, I request an help for the live search.. Here are the 2 pages Code: [Select] <html> <form action='?p=search'> <font face='sans-serif' size='5'> <center> Search By the CID.<br> <input type='text' size='50' name='search'> <input type='submit' name'submit' value='Search'> </center> </font> </html> Code: [Select] <?php //get data $button = $_GET['submit']; $search = $_GET['search']; if (!$button) echo "You Have to insert a Valid CID."; else [ if (strlen($search)<=2) echo "Search term too short.The CID contain 6 number"; else [ echo"You searcher for <b>&search</b><hr size='1'>" } } ?> Now i want the live search by the name of the profile... Can someone help me? I am using ajax live search to retrieve data from MySQL table. It works fine. However I noticed that it only returns a single result that matches the entire word instead of multiple results that match only the first couple letters. For e.g. DB Table ---------------- 1. Foot 2. Foot Path 3. Football ---------------- If I type "foo" in the ajax search field, it won't return any results. But if I type "foot", it'll return "Foot". It won't return the other two results that contain the letters "Foot". Here's my query $param_term = $_POST["term"] . '%'; $get_data = $db->prepare("SELECT name FROM table WHERE title LIKE :param"); $get_data->bindParam(':param', $param_term); $get_data->execute();
I was wondering how can I improve the above query so that it looks for all potential results based on partial matching of letters? The result pages is supposed to have pagination like google help me please
Well I usually run my scripts in CLI.. I have it do something then sleep for x amounr of settings, is there anyway to make it show me the seconds counting down instead of just a blinkin cursor? I bought script for live chat support but i want something more. Now you can login with admin role and operator role, but what i want is to add user role so when user login in app he can see online operators and chat with them. It is open source so there is no legal issue..
So if anyone wants to help me i will send script on your email and try to solve this..
Thanks,Ivan
Hi everyone,
I'm hoping the someone can guide me in the right direction for what I need to do. Does anyone know of a really good tutorial and/or information about a plugin product that is available to do what I need? For example, what I need is to create a website that has the ability to allow video conferencing between a teacher and students. This what I envision - a college professor can log on to his website and display a live video feed of him. Also, as each of his students log on, their live video feed is then also supplied. Would prefer a already made plugin product but would also like to look at raw code in PHP to see how something like this could be accomplished. Thank you in advance.
Charles
Hi, I am doing some scraping and processing in php that is time intensive. On my local machine it was no big deal, but now that the project is live and has realtime users daily I have some concerns. When php is processing does this mean other people can't connect to the server? (They will be queued until the process I am running finishes) ? I hope not, but my local testing seems like it IS that way. I did this: I ran a php script from my browser that took a few minutes to execute. While it was running I tried accessing the same local site via another browser tab and it halted. If this is in fact how php works on the live server, how would I go about running about 6000 processes daily that would consume ~1-4 hours of processing time?
Thanks.
Edited September 6, 2019 by fivestringsurf Hi there I'm a little bit of a newbie when it comes to PHP, and I have tried to find my answer on google and on other websites related to php development.
My question is what do I need to be researching / learning to automatically update a page with content.
For example, if I have a database field called breaking news and this text string is flashed at the bottom of the screen on a scrolling bar.
When the field changes value in MYSQL, I would like the page to automatically update the page without a need for a page refresh.
All I need is some advice on what I need to search for in order for me to learn the coding myself.
I'm thinking AJAX, but not too sure.
Thank you for reading.
I require a page to be added to my website. This page will facilitate a refined search via Google, Bing and Yahoo search engine simultaneously , show the top 5 of each engine. Is this possible using php ? Thank's This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=346821.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=327780.0 As we have been working on an eCommerce project, we want to add an option in the eCommerce, that user should have the live location tracking of delivery boy (as same as SWIGGY) in the website. Is there any chance to track the live location using PHP and JavaScript? Searched on the google but nothing resolved my problem? Please anyone suggest us to track the live location of the delivery boy. Thanks in advance Hello,
I have a pretty basic two panel design, no code yet but it is pretty straight forward
What I'm concerned about is how a website can react to an orientation change, not simply be re sizing but by relocating items.
So in portrait mode, I have panel a, the top half say 50%, and panel b, 50% bottom half
I rotate it (the phone) to the left of my perspective (viewer) and the top panel goes to the left, and the bottom panel goes to the right.
In the meantime some scrolling animation is in play and the direction of the scroll changes, from sideways to up and down...
Is that possible without refreshing the page?
Edited by greenace92, 04 December 2014 - 04:53 AM. Are there any editors that will allow me to edit live on my server? I'm looking for a free open source solution Failing that: what recommended paid ones are there? I'm using Vista so need a Windows version Thanks OM Hello, Does anyone know a tutorial I can follow to create my own search engine over the items I have in my SQL database? I find a lot of tutorials but they are all 'one word searches' which means if you type two words you will get all results that contain either word (too many hits). If the search engine tutorial displays result with AJAX even better. Thanks for help. df I have been working on a blog program with a tag system. When I add tags and ask to display them to a certain webpage they all appear on my WAMP environment but not my live server. Any thoughts as to why this might be? Here is the code needed to display the tags. I am not sure if maybe live servers have restrictions that might be stopping it from displaying.
This is on the main page to display the tags.
<div class="widget"> <?php echo '<h2>Tags</h2>'; echo '<ul>'; getTagCount($DBH); echo '</ul>'; ?> </div>Next here is the function from the includes file. function getTagCount($DBH) { //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name $stmt = $DBH->query("SELECT * FROM tags"); $stmt->execute(); $result = array(); $result = $stmt->fetchAll(); //For each row pulled do the following foreach ($result as $row){ //set the tagId and tagName to the id and name fields from the tags table $tagId = $row['id']; $tagName = ucfirst($row['name']); //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id $stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId); $stmt2->execute(); $tagCount = $stmt2->fetchColumn(); //Print the following list echo '<li><a href="blog_tags.php?tagId=' . $tagId . '"title="' . $tagName . '">' . $tagName . '(' . $tagCount . ')</a></li></form>'; //End of loop - start again } }The "tags" database is structured like so id, name The "blog_post_tags" is structured like so, blog_post_id, tag_id On the WAMP server it returns all of tags while the live server only returns the first one. Any suggestions on what is going on? If you need any other info please let me know. Hi
I'm looking for some advice on how to parse an xml feed and display any odds on my site
Here is an example http://feed.youwincd...in_football.xml
and as you can see it is quite large so calling it every time would have an impact on the server.
I am looking at using many different feeds in the future so want to start this properly and in a scaleable way.
I want to use php but open to any ideas on the best way to do this
Many thanks
Sam
hello sir, i have to connect database to my live server using <?php
define('DB_HOST', 'localhost'); ?> or
|