Tizag.com Webmaster Tutorials - A collection of webmaster tutorials from HTML to PHP.

Saturday, February 7, 2009

Browser Detection JavaScript

navigator.appName........ Browser name
navigator.appVersion..... Version

Detecting Firefox x.x

UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13

< script language = Javascript >
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ffversion>=3)
document.write("You're using FF 3.x or above")
else if (ffversion>=2)
document.write("You're using FF 2.x")
else if (ffversion>=1)
document.write("You're using FF 1.x")
}
else
document.write("n/a")
</script>

Detecting IE x.x


< script language = Javascript >
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ieversion>=8)
document.write("You're using IE8 or above")
else if (ieversion>=7)
document.write("You're using IE7.x")
else if (ieversion>=6)
document.write("You're using IE6.x")
else if (ieversion>=5)
document.write("You're using IE5.x")
}
else
document.write("n/a")
</script>

Thursday, February 5, 2009

Import data from EXCEL to MySQL

  1. Save your Excel data as a csv file (In Excel 2007 using Save As)

  2. Check the saved file using a text editor such as Notepad to see what it actually looks like, i.e. what delimiter was used etc.

  3. Start the MySQL Command Prompt (I'm lazy so I usually do this from the MySQL Query Browser - Tools - MySQL Command Line Client to avoid having to enter username and password etc.)

  4. Enter this command:
    LOAD DATA LOCAL INFILE 'C:\\temp\\yourfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2);