i want to add (+)to add more than textfield for phone

<form method="post" action="" enctype="multipart/form-data">
  <table width="800" border="0" dir="rtl" style="direction:ltr;">
   <tr>
      <td scope="col" style="direction:rtl;"><label for="textfield">name</label>
        
        <div align="right">
          <input type="text" name="person_name" id="person_name"/>
          </div></td>
     
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="textfield">job</label>
        
        <div align="right">
          <input type="text" name="person_job" id="person_job" />
          </div></td>
     
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label">mobile</label>
        
        <div align="right">
          <input type="text" name="person_mobile" id="person_mobile" />
          </div></td>
    
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label2" >phone</label>
        
        <div align="right">
          <input type="text" name="person_phone" id="person_phone" />
          </div></td>
    
    </tr>
    <tr>
      <td style="direction:rtl;"><label for="label3">email</label>
        
        <div align="right">
          <input name="person_email" type="text" id="person_email"   />
          </div></td>
      
    </tr>
    <tr>
      <td><label for="label4"></label>
        
        <div align="right"></div></td>
   
    </tr>
	 <tr>
          <td colspan="2"><p align="right">
              <input name="add" type="submit" id="add" value="add" />
          </p></td>
        </tr>
  </table>
</form>

and how to insert to mysql db?
any help?

Member Avatar for diafol

Just quickly - do you really want to use direction:rtl? Would text-align:right be more appropriate? AFAIK, rtl is used for right-to-left languages, not for simple alignment.

This is your barebones phone field:

<td>
 <label for="person_phone" >phone</label>
 <input type="text" name="person_phone[]" id="person_phone" />
</td>

I assume you mean add more <input> fields? You can add as many as you like, using the same: name="person_phone[]". This means the $_POST variable will be an array. Easy. However, DO NOT use identical ids - they must be unique. You can create dynamic inputs based on the number you want:

<?php
$num = 0;
while($num < 5){ //add 5 inputs
 echo "\n\t<input type=\"text\" name=\"person_phone[]\" id=\"person_phone_{$num}\" />";
 $num++;
}
?>

If you want javascript to generate these one at a time (with a [+] button), see jQuery for examples.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.