I need to check if a certain value ‘SheetNumber’ is in my mysql database dynamically. I have seen it done on popular web sites and I am trying to find a good tutorial to outline it for me. I am fairly new to Javascript but i know a lot of PHP.
I am anxious to learn how to do this.
- Chris
You will need to do this using Ajax. I recommend the Jquery library. Install it using the Jquery documentation, and then use something like the following:
Javascript:
You can have
makeAjaxRequest()invoked when someone clicks a link, clicks a button, or anything else, e.g:The php code of the file
script-that-checks-db.php(of course, name it something different) will be responsible for checking the db. The code would look something like this.PHP:
You could also use JSON here rather than the 0/1 method, but because you are new I think this will be simple enough for you.
Hope this helps, if you have any questions feel free to ask. Also, feel free to change the function and file names.