-2

ここに8つの列があります。シナリオは..ユーザーが以前の雇用記録を1つだけ持っている場合はどうなりますか?送信時に空白のままになっている他のフィールドを無視するにはどうすればよいですか?

雇用記録

    <table class="main" width="73%" border="0" align="center" cellpadding="0" cellspacing="2">
        <form action='scripts/forms_script3.php' name='forml' method='post'>
            <tr>
                <th>
                    Position Held
                </th>
                <th>
                    Company/Tel. No.
                </th>
                <th>
                    Immediate Head
                </th>
                    <th colspan="2">Inclusive Years<br/>&nbsp;&nbsp;From&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;To&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th>
                    Hiring Salary
                </th>
                <th>
                    Last Salary
                </th>
                <th>
                    Reason/s for Leaving
                </th>
            </tr>
            <tr>
                <td>
                    <input type='text' name='aposheld' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='acomtel' size='40' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='aimmhead' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='afrom' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ato' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ahsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='alsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='areason' size='45' maxlength='75'/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type='text' name='bposheld' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='bcomtel' size='40' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='bimmhead' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='bfrom' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='bto' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='bhsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='blsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='breason' size='45' maxlength='75'/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type='text' name='cposheld' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ccomtel' size='40' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='cimmhead' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='cfrom' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='cto' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='chsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='clsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='creason' size='45' maxlength='75'/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type='text' name='dposheld' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dcomtel' size='40' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dimmhead' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dfrom' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dto' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dhsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dlsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='dreason' size='45' maxlength='75'/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type='text' name='eposheld' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ecomtel' size='40' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='eimmhead' size='20' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='efrom' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='eto' size='5' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ehsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='elsal' size='8' maxlength='75'/>
                </td>
                <td>
                    <input type='text' name='ereason' size='45' maxlength='75'/>
                </td>
            </tr>
            <tr>
                <td colspan="8">
                    <div align="center">
                        <input type='submit' name='Submit' id='Submit' value='Save' />
                    </div>
                </td>
            </tr>

        </form>

    </table>
4

1 に答える 1

0

PHPループで?非常に簡単な例は次のとおりです。

$letters = array("a", "b", "c", "d", "e", "f", "g", "h");

foreach ($letters as $letter)
{
   // does one of the fields contain input
   if ($_POST[$letter.'posheld']!="" || $_POST[$letter.'comtel']!="" || $_POST[$letter.'immhead']!="" || $_POST[$letter.'from']!="" || $_POST[$letter.'to']!="") 
   {
      // process record
   }
}
于 2012-07-19T07:14:51.103 に答える