php - Multiple entries in SQL? -


how can store multiple entries in sql in 1 field? example in field phone want let users enter more phones private, home, business etc.

any hellp on how can create trat form , how store data in sql?

i guess can store them using serialize() function in php how make form , collect information?

form:  home phone: 321321333 other: 333213213 add 

also make can edit name field if users want put home tel instead of home phone or pager instead other.

any help? please?

user serialize(), said. however, working add button need javascript. here form:

<form action="action.php" method="post">     <div id="phonenumbers">         <input type="text" value="home phone">: <input type="text" name="0-value" value="(xxx)xxx-xxxx">     </div>     <button onclick="addanother();">add phone number</button>     <input type="submit> </form> 

here javascript (put in head tag of page):

<script type="text/javascript">     var nums=0;     function addanother(){          document.getelementbyid('phonenumbers').innerhtml+='<input type="text" name="'+++nums+'-name">: <input type="text" name="'+nums+'-value">';      } </script> 

here action.php:

<?php $arrayofnums=array(); foreach($_post $curval){     array_push($arrayofnums,$curval); } $serializedarray=serialize($arrayofnums); #now whatever code have add serializedarray database. string, easy. ?> 

now have serialized array in database. unserialize() , have array this, alternating between name , value: 'home tel','(324)444-4356','work tel','(444)546-5678' etc. untested, tell me if fails.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -