DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

PHP Interview Questions

By: Shailesh Singh | 04 Sep 2008 10:47 pm

I have some queries, can you please clarify it.

1. I have created HTML form with textbox, text area, radio button, check box, dropdown box.
How to get form name
and form element names (textbox, text area, radio button, check box, dropdown
box) in JavaScript dynamically.

2. I am using persistent connection (mysql_pconnect ()) for connecting database.
User A is browsing
my website. Now User B and C browsing my website.
What happens here B
and C are using same connection or creating new connection for each user?
If B and C use
same connection, is there any queue concept for allocating resources?

3. SELECT * FROM `emp` where ename In(select ename from emp group by ename having count(ename) >1).
I have 1000 records in EMP table. For executing above query it takes milliseconds.
I have 10Lacs records in EMP table. For executing above query it takes so much time.

How can I reduce that time?
How can i calculate query performance level in MySQL?

4. I have products table with field’s product id and product name.
I have 1000 records in products table. But 100 product names are wrong. For that, I am uploading new excel file and comparing excel product id and products table product id.
If it matches, I am updating that product name.
For the above process, I am using for loop, Select query and Update query. For 1000 records for loop is working fine.

What about, if products table have 10Lacs records and 1Lac product names are wrong.

Is for loop working?
If not what is the solution for executing 10Lacs records?

Thanks,

Comments

Ans for Q4
Without using loops concept,i found one solution. By using LOAD DATA INFILE.

1.I have product table with fields pid and pname.

2.I am uploading excel file by using browse option.

3.Now i am creating temporary table with fields tid and tname.

4.I am loading LOAD DATA INFILE into temporary table.

LOAD DATA INFILE "./a.xls" INTO TABLE temporary

5.By using below command,i am updating wrong product names.

Update product p
LEFT JOIN Temporary t
where p.pid=t.tid and p.pname!=t.tname
set p.pname=t.tname

6.Finally droping temporary table.
drop table if exists temporary;

If you need to count of wrong ones,by using mysql_affected_ rows() you will find the count.
By: PHP Guru | 05 Sep 2008
Ans 1Q
use *document.forms[ 0].name. *this
will give you the name of the first form in the page.
similarly using *document.forms[ 0].elements[ 0].name* you can get the name of
the first element in the first form
By: PHP Guru | 05 Sep 2008

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move