buy ipad 2

cheap ipad

ipad reviews

magento hosting

the ipad

ipad 2 prices

Ipad 3

ipads

price of ipad 2

ipad 2

zMastaa.com

Web Developer and Designer, Graphics Designer and Photographer in Manchester

Use jQuery to display number of rows in a mysql database on a form

August 10th, 2010

Im currently writing a search engine that uses a couple of jQuery UI autocompletes and comboboxes, and to spice things up a bit I thought I would add some kind of live updating script that shows the user how many results will be returned, depending on the current search settings BEFORE actually pressing submit/search

i.e.  the Autotrader car search does this pretty dam nicely.

This is my translation of this effect with jQuery and PHP/mysql

Note: This tutorial assumes you already have a form with jQuery auto-completes etc all with element id’s attached

First lets start of with the javascript that will be send the data to an external php file

 
 
function numRows() {
 
var querydb = $("formid").serialize();
 
$.ajax({
 
url: "checkNumRow.php",
 
dataType: "text",
 
data: querydb,
 
success: function(result){
 
$("#results").text(result);
 
},
 
});
 
}

The jQuery script is now ready to send a query to the php file checkNumRows.php whenever the function numRows() is called, it will also return the data to any tag named #results.

So now you want the function numRows() to be called whenever the user changes data on the unfinished form, simply add the following at the end of your javascript file

 
$(":checkbox, :radio").click(numRows);
 
$("select").change(numRows);
 
$("input").blur(numRows);
 
$("input").focusout(numRows); 
// I used focusout as well as blur because blur doesn't seem to 
// work well with auto complete input boxes
 
numRows();

Now that the javascript is ready you need to create a php file called checkNumRows.php and insert the following code below and populate it with your own code to search your database

 
/*
filename::checkNumRows.php
Build your mysql search string using $_POST["element.id"]
above this so hat you end up with something along the 
lines of
$sql = "MYSQL SEARCH STRING";
*/
$results = mysql_query($sql);
$numrows = mysql_num_rows($results);
if ($numrows=="1"){
// You can echo "insert html code here" to create something more complex
//  like the autotrader display
echo  $numrows . " result found";
} else {
echo  $numrows . " results matching the search criteria";
}

Now that is done your php file should be able to display the number of rows in your database depending on whatever your $_POST (the names of your form elements on your form) requests are.
For example a black three door car search might look like this

www.yourwebsite.com/checkNumRows.php?colour=black&doors=3
and should return something similar to
200 results matching the search criteria

Now this is done, back on the page with your form you just add this 1 line to display live results

Feel free to ask questions, I will provide as much help as possible

Find out who deleted you off their facebook friend list

December 30th, 2009

For the last couple of months I’ve always been intrigued into why my facebook friend count NEVER stays the same over a period of 24 hours, that is no exaggeration.

At 1pm it will be 1095, by 6pm it will be 1099 then at 12 midnight it will be 1093, this without adding any new friends or manually removing anyone. It got to me so much I thought this would be my perrfect “first” application to create using the facebook toolkit

 

Well let me cut to the chase, the application works like this

  1. First time the user logs onto the app, it will take a snapshot of the users current friend list.
  2. Second time the user logs onto the app, it will compare the current friend list with the previous snap shot, at this point the user will be given the option to “save” the friend list to create a new snap shot, or leave the old snap shot intact.
  3. If the user has indeed been deleted by someone, the application will provide a link to the profile of the user, if the link fails and redirects to the facebook homepage then the user actually de-activated their account.

 

Try for yourself here

Google Wave: Just Sick

July 22nd, 2009

Okay so anyone that knows me knows im into web development etc etc, ive created a few wordpress plugins when ive looked (googled) everywhere for a type of plugin and it hasn’t been made, i get to making it. This google wave in my eyes will change the way people communicate and im looking to be part of that change by creating a wordpress plugin that will do the following:

  • Create a “wave” linked to a new post/page
  • Display that wave beneath the wordpress post (where comments would usually be)

With googles brilliant API’s and Robot tools this is definately possible :D , just intime for uni

Wikipedia on Google Wave

Google Wave is designed as the “next generation” of Internet communication. Instead of sending a message and its entirethread of previous messages or requiring all responses to be stored in each user’s inbox for context, objects known as “waves” contain a complete thread of multimedia messages (blips) and are located on a central server. Waves are shared and collaborators can be added or removed at any point during a wave’s existence.

zMastaa.com

Web Developer and Designer, Graphics Designer and Photographer in Manchester

http://www.twitter.com/zMastaa http://fb.me/eugenesdesigns http://www.linkedin.com/in/eugeneagyeman HTML5 Design by WPlook