0

***Here Is My Code****

           <form name="f1" method="post" action="middle1.php"> 

*Here It Is Getting The Row Data From DB into array format and i placed dat data into variable data1***

                              <?
                              $user=$_SESSION['user'];
                              $data1= array();
                              $data1= $obj->pcode($user);
                              $dat=  count($data1);
                              // echo $dat;
                              ?>

***Here Using The data1 variable am trying to print the all rows present in the DB*

                        <?if($data1!=''){
                                   for($i=0;$i<=$dat;$i++){
                                 ?>
                         <tr> <td width="52" height="28" align="center"bgcolor="#E1E1E1" class="cal_txt_black">

*Here is the problem how can i mention that it hav to print the first row then so...on in the php echo statement**

                              <input name="pcode" type="" value="<? echo $data1['projectcode']; ?>" size="1"  border="0" style="background-color:D8D8D8"></td>
                                <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black" style="border-right:1px solid #D8D8D8;"><input name="mon" type="text" value="<? echo $data1['mon']; ?>" size="1"  border="0" style="background-color:White"></td>
                                    <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black"><input name="tue" type="text" value="<? echo $data1['tue']; ?>" size="1"  border="0" style="background-color:White"></td>
                                    <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black"><input name="wed" type="text" value="<? echo $data1['wed']; ?>" size="1"  border="0" style="background-color:White"></td>
                                    <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black" ><input name="thu" type="text" value="<? echo $data1['thu']; ?>" size="1"  border="0" style="background-color:White"></td>
                                    <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black"><input name="fri" type="text" value="<? echo $data1['fri']; ?>" size="1"  border="0" style="background-color:White"></td>
                                    <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black"><input name="sat" type="text" value="<? echo $data1['sat']; ?>" size="1"  border="0" style="background-color:White">
                                            <td width="52" height="28" align="center" bgcolor="#ffffff" class="cal_txt_black" style="border-right:1px solid #D8D8D8;"><input name="sun" type="text" value="<? echo $data1['sun']; ?>" size="1"  border="0" style="background-color:White"></td>

                                            <td width="52" height="28" align="center" bgcolor="#D8D8D8" class="cal_txt_black" style="border-right:1px solid #ffffff;" ></td>
                                            <td width="52" height="28" align="center" bgcolor="#D8D8D8" class="cal_txt_black" style="border-right:1px solid #ffffff;"></td>
                                            <td width="52" height="28" align="center" bgcolor="#D8D8D8" class="cal_txt_black" style="border-right:1px solid #ffffff;"></td>


                               <td><input name="save1" class="btn_login" type="submit" value="Save" align="center" formaction="middle2.php"></td>         
                            </tr>
                               </form> 
                                   <? }

                                   }?>
4

1 回答 1

1

简单地在循环中使用 $i 变量

for($i=0;$i<=$dat;$i++){
  ?>

<input name="pcode" type="" value="<?php echo $data1[$i]['projectcode']; ?>" size="1"  border="0" style="background-color:D8D8D8"></td>


<?php } ?>
于 2013-05-17T10:22:51.390 回答