Hi, when I was working on the registration form of conference, how many persons will be available , and informations of users (name,email,phone,address). I was thinking instead of typing user info one by one. I have design the input area as tabular form. There is add user button on the screen through which dynamicly created input box. Of the input boxes..
Name | Phone | Email | address |
User 1 | Dummy data | Dummy data | Dummy data |
User 2 | Dummy data | Dummy data | Dummy data |
User 3 | Dummy data | Dummy data | Dummy data |
Submit Button will be here |
Now the issue that I have faced that I need that data in well managed form. So this case I have got two solutions .
Solution 1 (By Modifying input tag id’s and name ).
In this solution I have to named the input tags according to the users detail which you can see in the following example
<form method="post" action="">
<input type="hidden" id="user1[name]" name="user1[name]" value="developer99"/>
<input type="hidden" id="user1[phone]" name="user1[phone]" value="03322222222"/>
<input type="hidden" id="user1[email]" name="user1[email]" value="aa@aa.com"/>
<input type="hidden" id="user1[address]" name="user1[address]" value="dummy"/>
<input type="hidden" id="user2[name]" name="user2[name]" value="developer"/>
<input type="hidden" id="user2[phone]" name="user2[phone]" value="0321229111"/>
<input type="hidden" id="user2[email]" name="user2[email]" value="test@test.com"/>
<input type="hidden" id="user2[address]" name="user2[address]" value="dummy"/>
<input type="submit" id="submit" name="submit" value="submit"/>
</form>
And when I have submit the form I have got the values in the following manner, this is the print of $_REQUEST
Array
(
[user1] => Array
(
[name] => developer99
[phone] => 03322222222
[email] => aa@aa.com
[address] => dummy
)
[user2] => Array
(
[name] => developer
[phone] => 0321229111
[email] => test@test.com
[address] => dummy
)
[submit] => submit
)
you can see this is the simple method you can have passing an array through it..
Solution 2 (By JSON ).
JSON is lighter way then xml to pass the values through ajax or in webservices.. but it can use in post form also. Below is the code of javascript.
Var usersInfo = new Array();
var o = new Array(Name,phone,email,address);
var o1 = new Array(Name,phone,email,address);
var o2 = new Array(Name,phone,email,address);
usersInfo[0] = o;
usersInfo[1] = o;
usersInfo[2] = o;
usersInfo = JSON.encode(usersInfo);
document.getElementById(‘arrayOfUsers’).value= escape(base64Encode(usersInfo));
I have encoded this JSON value in base64 encode as some time special chars can create problems .
And after post you have to decode it through base64 decode and json decode..
To know much about JSON you can visit up this link
http://json.org/
hey !!
ReplyDeleteThis is a very nice article..
But what i don't get is what if we have to use both MyISAM and INNODB...in such a case if we have DML's in a transaction INNODB tables will rollback, but how to ensure atomicity in the MyISAM tables ?
Your reply will be of great help.
Thanks in Advance
yes there is minor problem that MyISAM didnot support Transactions... and innoDB are more relialbe on atomicity... but you can solve that problem by your own programmming design... you can achieve that by random no method.. you can achieve parallelism also ..
ReplyDeleteI like your Yoda style of speaking 99 Developer!
ReplyDeleteThere IS full text search in InnoDB now.
ReplyDeleteYour comparision table is good but I d'nt agree with your comment "if there is any doubt which to use when. then MyISAM is your default choice."
ReplyDeleteAs per me if you have sufficient resources (CPU/RAM/Space) and you have any doubt that which engine to use, then go with Innodb.
i'am using very frequent insert queries. that's why my table engine is innodb.
ReplyDeleteThis is a good article that just open my mind, I never really realize about the engine as I just got a major error that required me to do the research thank you.
ReplyDeleteThis is useful for me. You said frequent "insert, update, select, delete" InnoDB or MyISAM. My online store project, I have new products, new members which engine should I use? Thank you.
ReplyDelete