how to retrieve from database..... this format (PRMRMDU402).
firstname= prabhu, lastname=kumar, city=madurai,
pincode=624402....

i want first name first two letters and last name last two
letters ... city first two letters ... pin code last three
letters....

Answers were Sorted based on User's Feedback



how to retrieve from database..... this format (PRMRMDU402). firstname= prabhu, lastname=kumar, cit..

Answer / gaurav

$record = mysql_fetch_array(".........");
$fn = substr($record['firstname'], 0, 2);
$ln = substr($record['lastname'], -2);
$ct = substr($record['city'], 0, 2);
$pc = substr($record['pincode'], -2);

$final = strtoupper($fn.$ln.$ct.$pc);

echo $final;

Is This Answer Correct ?    4 Yes 2 No

how to retrieve from database..... this format (PRMRMDU402). firstname= prabhu, lastname=kumar, cit..

Answer / ajit

SELECT SUBSTRING(`firstname`,1,2) as 'firstname',SUBSTRING
(`lastname`,-2) as 'lastname',SUBSTRING(`city`,1,2) as
'city',SUBSTRING(`pincode`,-3) as 'pincode' FROM
`user_info` WHERE 1

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Tell me what does the array operator '===' means?

0 Answers  


Design a class that should always return a single object ?

3 Answers   NIIT,


Differentiate echo vs. Print statement.

0 Answers  


What is the difference between query and question?

0 Answers  


Are static variables final?

0 Answers  






What is the meaning of php?

0 Answers  


what is interface in php? how it is use?

10 Answers   Infosys, PHP, Times, Torque Infotech, Wipro,


How do you check if a variable has not been set in php?

0 Answers  


What is meant by urlencode and urldecode?

0 Answers  


How is it possible to remove escape characters from a string?

0 Answers  


How to check if a string contains a character or word in php?

0 Answers  


What is a composer?

0 Answers  


Categories