Posts

Showing posts with the label MySQL

Typeahead Implementation in PHP/MySQL

DEMO First, you need to include all the necessary files for this to work. Place these three files in the head section of your page.. jquery-1.10.2.min.js  bootstrap.min.js bootstrap3-typeahead.min.js Then, this script: $(document).ready(function () { var objects = []; var map = {}; $('#person').typeahead({ source: function (query, process) { $.ajax({ url: 'get_person.php', type: 'POST', dataType: 'JSON', async: true, success: function (data) { objects = []; //resets the objects map = {}; //to avoid duplication $.each(data, function (i, object) { map[object.full_name] = object; objects.push(object.full_name); }); process(objects); } }); }, //end source ...

Show Search Results in a Pop-up Div

Image
It uses MySQL as the database. Basically, the search results will pop up. Here's the code below:

Load MySQL Data using JQuery

Image
Of course, you won't be redirected to another page to see the result. That's the best thing about JQuery , although AJAX can also do it. Anyway, here's the code snippet for the user's side.. <input id="datepicker" maxlength="20" type="text" /> <div id="refresh_img">Select Date to Load images..</div> <script type="text/javascript"> $(document).ready(function(){ $('#datepicker').change(function(){ var variable = document.getElementById('datepicker').value; $('#refresh_img').load('query/getprojimg.php',{"variable": variable}).fadeIn("slow"); }); }); </script> And for the server side.

Simple Log-in/Logout and Registration with Session and Blowfish Encryption

Image
This simple login and logout PHP script uses Blowfish Encryption for its password security here's the screenshot: Download Source Code Database Name: dblogin

Create A Simple Timestamp in PHP, MySQL

Image
Well, here's the screenshot 'coz I'm too lazy to explain it. Here's the code for reference: index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Time Ago</title> <style> #stamp{ background-color:#CCCCCC; } </style> </head> <body> <p>Create a Database by clicking the button below then sign-up the form.</p> <form method="post" id="createdb" action="createdbandtables.php"> <input type="submit" class="submitdb" value="Create DB" /><br/> </form> <form action="reguser.php" method="post" name="userreg"> <table...

Disable Submit/Save Button if Value Exists from MySQL Database

Image
As shown below: Download Source Code First you need to create a database and name it as "syllabus" then import the sql file from the source code. Here are the codes below for reference:

Showing and Hiding MySQL error in PHP

You might ask why we hide an error, 'cause it should be fixed right? Anyway, there are instances that we just need to hide it. Let's say for example, "undefined index" error/warning in this case: I have this table with unique attribute names in every "input" elements: ID Name 1 Eds 2 Matt We don't know how many value that the user will input, so I assume that he/she will always input eight(8) values. I must fetch the value from that table by assigning them to a variable. If the user will  input less than eight(8), a warning or error will show "undefined index..". In this case, I just hide it.

Delete Duplicate Values but Retain One in MySQL

I'm not good at explaining so, let's just demonstrate it. Say for example ( although this is some sort of explanation ) we have this table in our database: Table Name: tag NAME ID test 1 test 2 test 3 again 4 again 5 nodup 6 with this query, DELETE a FROM tag a LEFT JOIN ( SELECT MIN(id) AS id, name FROM tag GROUP BY name ) b ON a.id = b.id AND a.name = b.name WHERE b.id IS NULL; ...the result will be NAME ID test 1 again 4 nodup 6