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

What is the delimiter syntax is PHP's default delimiter syntax

0 Answers  


Which function can be used to exit from the script after displaying the error message?

0 Answers  


What is php used for?

0 Answers  


What is the difference between php and javascript?

0 Answers  


What is the difference between laravel and php?

0 Answers  






What is abstract class php?

0 Answers  


What is the difference between $var and $$var?

0 Answers  


What is singleton pattern in php?

0 Answers  


How to link one site backend to another site frontend?

0 Answers   Global Logic,


What is php in simple words?

0 Answers  


Describe the security vulnerability of PHP?

0 Answers  


Suppose your zend engine supports the mode <? ?> Then how can you configure your php zend engine to support <?php ?> Mode ?

0 Answers  


Categories