Wednesday, February 23, 2011

How to show date in dd-mmm-yyyy format in php


if you are retrieving date from MySQL table in the format yyyy/mm/dd (e.g. 2005-02-10) and you want to display the date in
converted format like dd-MMM-yyyy (e.g. 10-Feb-2005) in PHP.

Use this code for it ...

Use PHP's date and strtotime:

$output = date('d/M/Y', strtotime($date_from_mysql_Table_Field)) ;

Or use MySQL's built in DATE_FORMAT function:

SELECT DATE_FORMAT(datetime, '%d/%b/%Y') datetime FROM table


Saturday, January 29, 2011

How to Add days, weeks, months, years to dates in PHP

How to Add days, weeks, months, years to dates in PHP

As you probably know php gives you a nice date() function that allows you to get a date and format it using a vast amount of unix date strings. But what if you want to add/subtract days, weeks and months to a date?

You can add any amount of time to a date in php using the strtotime function, this will allow manipulation of a date once it has been converted to a unix time string. See the example below:

$today = date("Y-m-d");// current date
$tomorrow = strtotime(date("Y-m-d", strtotime($today)) . " +1 day");
$output = date("Y-m-d", $tomorrow);

So the first line gets todays date, then the next command gets today and converts it to a time string with the modifier +1 day. This can be days, week, month or year depending on the requirements. Then we reformat the string as a date to output it. It’s really that simple.



Sunday, January 2, 2011

Internet and Web Technologies - Multiple Choice/Objective Questions (Part 1)


1. This lightweight protocol provides a way for programs to interact with each other, even if using different operating systems and located behind a firewall.
a. CORBA
b. SOAP
c. RMI
d. DCOM

Ans :- b


2. This platform simplifies application development and decreases the need for programming and programmer training by creating standardized,reusable modular components.
a. GDMO
b. JES2
c. J2EE
d. JNDI

Ans :- c


3. What technology is being referred to as Web 3.0?
a. Open Source Technology
b. The Semantic Web
c. Read Write Web
d. Social Networking

Ans :- b


4. This method ensures that each XML element type and attribute name has a unique identity.
a. namespace
b. fully-qualified domain name
c. Multiprotocol Label Switching
d. named pipe

Ans :- a


5. This term encompasses the plans, methods, and tools aimed at modernizing, consolidating, and coordinating the computer applications in an enterprise.
a. EAI
b. EDI
c. grasping plan
d. decision support system

Ans :- a


6. This markup language is considered to be extensible because of its unlimited and self-defining markup symbols.
a. HTML
b. XHTML
c. XML
d. W3C

Ans :- c



7. This XML-based registry is intended as on online Internet registry for businesses worldwide.
a. Universal Plug and Play
b. UDDI
c. Uniform Resource Locator
d. UDF

Ans :- b


8. This application program interface (API) from Sun Microsystems supports messaging between computers in a network.
a. write once, read many
b. Short Message Service
c. Simple Mail Transfer Protocol
d. Java Message Service

Ans :- d


9. Scribd is:-
a. email client
b. blog
c. chat server
d. file sharing repository

Ans :- d


10. This XML extension is a standard way to describe how to transform the structure of an XML document into an XML document with a different structure.
a. extract, transform, load
b. tree structure
c. XSLT
d. phase change

Ans :- c


11. This is a data structure representing a service type in a Universal Description, Discovery, and Integration registry.
a. model-view-controller
b. tModel
c. Venn diagram
d. exploratory model

Ans :- b


12. When was IE8 released?
a. March 19th 2009
b. March 19th 2008
c December 10th 2008
d. January 21st 2009

Ans :- a


13. Mozilla Thunderbird is an Internet browser
a. True
b. False

Ans :- b


14. Name the founder of Wikipedia?
a. Tim Shell
b. Jimmy Wales
c. Jason Richey
d. Bomis

Ans :- b


15. This XML-based language is used to describe the services a business offers and to provide a way for individuals and other businesses to access those services electronically.
a. Xerces
b. X-Box
c. XUL
d. WSDL

Ans :- d



16. How much did News Corp. pay for MySpace?
a. $580 Million
b. $440 Million
c. $ 290 Million
d. $880 Million

Ans :- a


17. PHP stands for:-
a. Preprocess Hypertext
b. Preprocessor Hypertext
c. Hypertext Preprocessor
d. None


Ans :- c



18. What does AJAX stand for?
a. Asynchronous JavaScript & XML
b. Automatic JavaScript & XML
c. Asynchronous JavaScript & XHTML
d. Adaptive JavaScript & XML

Ans :- a


19. At which site can you just click on the word's first letter if you don't know how to spell the whole word?
a. Google
b. Yahoo! Kids
c. Kidsclick
d. Ask for Kids


Ans :- c



20. RSS stands for:-
a. Really Simple Standards
b. Really Simple Synonyms
c. Really Simple Syndication
d. Really Simple Specifications

Ans :- c

Internet and Web Technologies - Multiple Choice/Objective Questions (Part 2)


1. Who contributed the term “Hypertext”?
a. Tim Bernes Lee
b. Scott E. Fahlam
c. Ted Nelson
d. William Gibson

Ans :- c

2.
Syntax of PHP is similar to:-
a. Perl or C
b. Perl and C
c. Only C
d. Only Perl

Ans :- b

3. Google bomb is:-
a. Spam Mail
b. Shared Network
c. Successful Bloggers
d. Inflate Website’s Search Ranking

Ans :- d

4. What is not an area of study within Human Factors research?
a. Human Anatomy
b. Human performance
c. Technology design
d. Human and technology interaction

Ans :- a

5. Google was founded by:-
a. Larry Page & Sergey Brin
b. David Filo & Jerry Yang
c. Jeff Bezos
d. Shawn Fanning

Ans :- a

6. Archy is:-
a. keyboard driven UI
b. Mouse driven UI
c. Joystick driven UI
d. both a & b

Ans :- a

7. Which is the earliest social networking site?
a. classmates.com
b. orkut.com
c. facebook.com
d. None

Ans :- a

8. Modem stands for:-
a. Modulator & Demodulator
b. Memory Demagnetization
c. Monetary Devaluation Exchange Mechanism
d. Monetary Demarkation

Ans :- a


9. Which of the following interface design principles does not allow the user to remain in control of the interaction with a computer?
a. allow interaction to interruptible
b. allow interaction to be undoable
c. hide technical internals from casual users
d. only provide one defined method for accomplishing a task

Ans :- d


10. Which of the following is not a method of accessing the web?
a. ISDN
b. DSL
c. Modem
d. CPU

Ans :- d

11. The Macintosh menu bar is faster than the Windows menu bar primarily because of:
a. the power law of practice
b. task analysis
c. Fitt’s Law
d. perceptual fusion

Ans :- c

12. Two different principles widely used in GUI design are Application oriented interfaces and:-
a. Object User Interfaces
b. Object Oriented User Interfaces
c. Touch interfaces
d. Attentive User Interfaces

Ans :- b

13. Which model depicts the image of a system that an end user creates in his or her head?
a. design model
b. user model
c. system model
d. system perception

Ans :- d


14. You can load a VCR tape the right way because of:
a. physical constraints
b. logical constraints
c. semantic constraints
d. cultural constraints

Ans :- a

15. WUI stands for:-
a. Web –based User Interface
b. Web User Intelligent
c. Web Urgent Interface
d. None

Ans :- a


16. What is GOMS?
a. Goals, Operations, Module, Selection
b. Goals, Operators, Methods, Selection
c. Goals, Operating system, Methods, Selection
d. None

Ans :- b


17. JavaScript was originally called as:-
a. Java web scripting
b. LiveScript
c. HTML Jscript
d. None

Ans :- b


18. CLI stands for:
a. Class Line Interface
b. Computer Line Interface
c. Command Line Interface
d. None

Ans :- c


19. BCI stands for:-
a. Brain Chip Interface
b. Brain Computer Interconnection
c. Brain Computer Interface
d. None

Ans :- c


20. Which of the following interface design principles reduces the user's memory load?
a. define intuitive shortcuts
b. disclose information in a progressive fashion
c. establish meaningful defaults
d. provide an on-line tutorial
e. answers a, b and c

Ans :- e


21. Who is NOT involved in Human Factors research?
a. Animals
b. Scientists
c. NASA
d. Technology designers

Ans :- a


22. What is human-centered design?
a. Design of human beings
b. A term used in drawing
c. A teaching method
d. A methodology in technology design

Ans :- d


23. Which model depicts the profile of the end users of a computer system?
a. design model
b. implementation model
c. user model
d. user's model

Ans :- c


24. User Interfaces are commonly programmed using:-
a. application driven architecture
b. network driven architecture
c. event driven architecture
d. None

Ans :- c

Friday, June 25, 2010

Remove duplicate characters in a string in VB


A simple code to remove duplicate characters in a string. Is there any better solution?

Public Function DuplicateTrim(ByVal Value As String) As String

Dim ASCII As Integer
Dim Temp As String

For ASCII = 33 To 126
' Get first location of the letter
If InStr(1, Value, Chr(ASCII), CompareMethod.Binary) > 0 Then
' letter exists
Temp &= Chr(ASCII)
' Remove all characters matching in original
Value = Value.Replace(Chr(ASCII), "")
End If
Next

Return Temp

End Function

How to show running serial no. in SQL SERVER Select Statement


I am working on a project where the SQL is generated at runtime depending on users selection and i am show the records from database in a Gridview control.
I am to show Running Serial Nos. as Serial No. column as the first column in the grid.

The solution to this requirement is to to genarate SR.No column in SQL as follows

SELECT ROW_NUMBER() OVER (ORDER BY ColumnName1) As Sr_No, ColumnName1, ColumnName2 FROM TableName


Monday, April 5, 2010

Sending Email from ASP.NET (C# or CSharp and VB) webpage using your Gmail email account.

C#/CShapr CODE
using System.Net.Mail;


MailMessage mail = new MailMessage();
mail.To.Add("toEmail@gmail.com");
mail.From = new MailAddress("fromEmail@gmail.com");
mail.Subject = "Subject of Email" ;

string Body = "This is a body of Email";
mail.Body = Body ;
mail.IsBodyHtml = true ;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("fromEmail@gmail.com", "yourPassword");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
try
{
smtp.Send(mail);
Label1.Text = "eMail Send OK... ";
}
catch (Exception ex)
{
Label1.Text = "Error Sending eMail: " + ex.Message.ToString();
}

--------------------
VB Code

Imports System.Net.Mail

Dim mail As New MailMessage
mail.To.Add("toEmail@gmail.com")
mail.From = New MailAddress("fromEmail@gmail.com")
mail.Subject = "Subject of Email"
Dim body As String
body = "This is a body of Email"
mail.Body = body
mail.IsBodyHtml = True
Dim smtp As New SmtpClient
smtp.Host = "smtp.gmail.com" ' //Or Your SMTP Server Address
smtp.Credentials = New System.Net.NetworkCredential _
("yourEmail@gmail.com", "yourPassword")
'Or your Smtp Email ID and Password
smtp.EnableSsl = True
Try
smtp.Send(mail)
Label1.Text = "eMail Send OK... "
Catch ex As Exception
Label1.Text = "Error Sending eMail: " + ex.Message
End Try