I was looking for tutorials on how to create " Ajax auto suggest " script for our company's phone booking system. I work for my uncle in cars re-selling company, and I really need to crate this script for my boss. I well about HTML, CSS and have average knowledge about PHP and MYSQL. I've actually create a search system but, I found this
http://www.w3schools.com/php/php_ajax_livesearch.asp
tutorial on how to create a live search. The only problem is that, they use XML, and that is complete chines to me. So, instead of using XML to store the data of our phonebooks, I would like to use mysql instead.
Is this possible at all? if so, any link/suggestion would be really nice.
thanks
Don't try to run before you can walk: first, write a simple search form which you submit and it runs some SQL to find the right results.
Once that's done, all a "live search" requires is JavaScript that quietly submits the form while you're typing and shows the top few results in an appropriate way.
You may also want to look at an auto-complete plugin, such as this one: http://jqueryui.com/autocomplete/ Again, write the code to search your database first, then adapt it to fit what the JavaScript needs.
Related
I would like to create an interface in my website with HTML and CSS so that the admin can make articles to be shown on the home page. But I don't how I could make the paragraphs and break-rows to seem correctly without being together.
What functions should I use or create to make a good validation?
I'm going to send the information from this interface to a database. From the database, I'll retrieve the information and show it on the home page.
Besides, do you have any suggestions to give me?
I'm not gonna lie; if you're new to PHP, building your own content management system will be difficult.
Learning is always a worthy goal. I suggest familiarizing yourself with the PHP documentation.
Start small. Build just the admin page first and see what you're in for. You'll probably want a rich text editor, username and password for the admin (NB - How to verify passwords properly!), etc.
For the line breaks and styling? Format paragraph elements using CSS.
For the interactive HTML and validation, if you are already familiar with HTML and the Javascript DOM, I would suggest learning to use a data binding library- AngularJS, Bootstrap, KnockoutJS or something similar. That will simplify your HTML interactions dramatically. If you are just a beginner, learn how to manipulate the page using Javascript.
I'm assuming you are familiar with databases in general? PHP works well with MySQL.
Search for what do you don't know. This isn't a tutorial site, but it isn't hard to find a tutorial to fill you in with exactly what you need.
On your journey, remember, search is your friend.
Today I need to start something special on my website.
I want to create an INSTANT SEARCH which will search within my posts.
A good example is this one: https://stackoverflow.com/users
Another one is: https://sublime.wbond.net/
I don't know from where to start. Any suggestions will be awesome.
PS: I don't need to use any wordpress plugin.
No search will ever be 'INSTANT', the closest you will get is searching existing DOM elements. I'm going to assume you want some kind of AJAX search.
Here are the relevant links
http://api.jquery.com/jQuery.ajax/
http://en.wikipedia.org/wiki/Ajax_(programming)
I assume your going to use jQuery as it seems in this situation there is no need not to (no need to reinvent the wheel), a couple of google searches will take you a long way as there is a lot of information on this subject and a good amount of tutorials out there.
The basic outline of the process is below
User enters input
This fires an ajax request
Server receives POST/GET values and performs a search
Server now outputs that data in a JSON format or pre-rendered HTML
The javascript will receive this data and render it (if JSON) into HTML or append the pre-rendered HTML to some element.
If you need some more direction let me know.
I am new to PHP. I know a little JavaScript, HTML, MySQL and lots of non-web computer programming.
I know how to create an HTML page with a form, use a button to call an external PHP file (with $_POST) which sends an email and records that forms data (names and email addresses) into a MySQL database.
Now, I'd like to create a new HTML page that calls an external PHP file (so the code is hidden) that will return the MySQL data (names and email addresses) for display on that existing HTML page (with all its CSS formatting and menus). In otherwise, I'd like to modify an existing HTML page with data (but hide the PHP code in an external file).
If this can be done (I'm new to this), can some please help by giving me at least the general idea so that I can build upon it. The textbooks that I've flipped through simply explain how to "echo" data back to the screen (a blank screen) with a .php extension in the address bar.
Thank you very much for your time and any help. I appreciate it!
Since you already have the html to echo part, you'll just need to plug it into the database.
Using a good ORM can help with this. For PHP, I recommend starting with Propel:
http://propelorm.org/
Once you get a bit more comfortable with that, you might want to try using a PHP framework, like Symfony, to help you structure the project in a more uniform way. However, there are many other PHP frameworks out there, so try to evaluate the top ones before settling on a favorite.
Furthermore, the examples provided in PHP framework documentations will guide you through many of the common solutions (as a framework is just a toolkit built by people who have had to solve such problems over and over).
For example, here is the cookbook for symfony that outlines many solutions to common issues.
For a system I am developing I need to programmatically go to a specific page. Fill out one field in the form (I know the id and name of the input element), submit it and store the results.
I have seen a few different Perl, python and java classes that do this. However I would like to do this using PHP and havent found anything as of yet.
I do have the permission to do this from the site i am getting the information from as well.
Any help is appreciated
Take a look at David Walsh's simple explanation.
http://davidwalsh.name/curl-post
You can easily store the response (in this example, $result) in your database or logfile.
Usually PHP crawlers/scrapers use CURL - http://php.net/manual/en/book.curl.php.
It allows you to make a query from the server where PHP runs and get response from the website that you need to crawl. It returns response data in plain format and parsing it is up to you. You can manually check what does the form submit when you do it manually, and do the same thing via curl.
You also may try phpcrawl (http://phpcrawl.cuab.de), seems to fit all your needs.
(See "addPostData()"-method)
I'm working on a editing tool (type of a simple CMS) in PHP/MySQL for a product catalog. I have search the Internet for a solution but I don't even know what to search for. So now my hope is on you guys.
I have a form where you can put all kinds of data like part.no, description an so on. All of this data is saved into a MySql table (items). I also have a table with predefined specifications.
What I want to do, and that I can't find a solution for, is to have a dropdown meny (or similar) and a add button to add a row for each related specifications without saving the whole form each time. I want to save first when all specifications is selected.
So, can I use PHP for this or do I need jQuery/Javascript or similar? I know it's possible, have seen it in OpenCart :-)
I hope someone understands my question. It's hard to explane i a language I'm not fully manage.
Regards
Client-side vs Server-side
Javascript: This sits in the user's browser. So anything you want to move in the user's browser will be done with JavaScript. This is "client-side"
PHP: This site on the server, so takes inpute from the user's browser and gives back a response (generally HTML, but can also be JSON or XML which is read by Javascript.). This is "server-side".
Libraries
jQuery: This is a set of functions written for Javascript to make it easier. So it runs in the user's browser and makes it easier for you to write bits that move on the screen.
You get similar libraries that help you write PHP (commonly called "frameworks") and there are many others for javascript as well.
Where to start
Write your HTML page as you want it to look. Keep it simple for the first time.
Then write some javascript (possibly using jQuery) to move the menu. Google "jquery menu dropdown" or similar and you'll find a solution you cna customise.
Then write some PHP that gives you the HTML you wrote in '1'.
Then decide what's going to happen when you click on a link in the HTML, and repeat the process (write HTML, incorporate Javascript to make it move, write PHP to give HTML)
Then work out which bits of the HTML are common or structured and should come from a database.
Without writing it for you (in which case you'll never learn) best to start one bit at a time and build as your knowledge grows. Bucket loads of examples on the web when youreach a particular problem you need to solve.
After comment "[how to] make it possible to select and add single/multiple specifications (from another table) without saving the whole form each time a specs is added":
Growing with AJAX
What you are asking is AJAX - this is where you get Javascript to talk to the server, and for javascript to move bits on the page based on the results. jQuery is probably the easiest (and probably has best documentation / examples for the ajax, as well as moving the DOM).
Basically: you have an "event" that you trap in JavaScript, example
/// Using jQuery to trap a button click
$().ready( function() {
$("#ButtonID").click( function(e) {
e.preventDefault();
alert('Button Clicked');
});
});
Then you build in an AJAX call inside that event (also check out get or post as the syntax is easier, you just get less control). The AJAX wil send a request to your PHP server, and you can get PHP to return HTML which you can replace/insert using the DOM manipulation functions linked below (e.g. before, html etc) or, when you get more advanced, you'll send back JSON which is a data structure you cna more easily manipulate in JavaScript to stipulate what actions are required.
As above, without actually writing it for you, the best place to start is to read the docs and have a go. Google "jquery AJAX PHP table example" or similar and you'll find an example somewhere.