mgjj 发表于 2015-8-29 09:24:38

php动态创建表单

1 <html>
2   <body>
3             <?php
4             $hnb_num=0;
5             $hnb_ip=array();
6             $ue_num=0;
7             $ue_id=array();
8             $ue_context_id=array();
9             $ue_cs_rua_status=array();
10             $ue_cs_ranap_status=array();
11             $ue_ps_rua_status=array();
12             $ue_ps_ranap_status=array();
13
14             exec("cmdcli 172.21.22.97 cn php", $output);
15             $k=0;
16             $line=$output[$k++];
17             $temp=split(" ",$line);
18             $hnb_num=$temp;
19             for($iter=0;$iter<$hnb_num;$iter++){
20               $ue_id_t=array();
21               $ue_context_id_t=array();
22               $ue_cs_rua_status_t=array();
23               $ue_cs_ranap_status_t=array();
24               $ue_ps_rua_status_t=array();
25               $ue_ps_ranap_status_t=array();
26               $line=$output[$k++];
27               $temp=split(" ",$line);
28               $hnb_ip[$iter]=$temp;
29               $line=$output[$k++];
30               $temp=split(" ",$line);
31               $ue_num=$temp;
32               for($i=0;$i<$ue_num;$i++){
33                     $line=$output[$k++];
34                     $temp=split(" ",$line);
35                     $ue_id_t[$i]=$temp;
36
37                     $line=$output[$k++];
38                     $temp=split(" ",$line);
39                     $ue_context_id_t[$i]=$temp;
40
41                     $line=$output[$k++];
42                     $temp=split(" ",$line);
43                     $ue_cs_rua_status_t[$i]=$temp;
44                     $ue_cs_ranap_status_t[$i]=$temp;
45
46                     $line=$output[$k++];
47                     $temp=split(" ",$line);
48                     $ue_ps_rua_status_t[$i]=$temp;
49                     $ue_ps_ranap_status_t[$i]=$temp;
50               }
51               $ue_id[]=$ue_id_t;
52               $ue_context_id[]=$ue_context_id_t;
53               $ue_cs_rua_status[]=$ue_cs_rua_status_t;
54               $ue_cs_ranap_status[]=$ue_cs_ranap_status_t;
55               $ue_ps_rua_status[]=$ue_ps_rua_status_t;
56               $ue_ps_ranap_status[]=$ue_ps_ranap_status_t;
57             }
58             ?>
59 <?php
60             echo "<form name='form1' method='post' action='action.php'>";
61             for($iter=0;$iter<$hnb_num;$iter++){
62               $ue_id_t=$ue_id[$iter];
63               $ue_context_id_t=$ue_context_id[$iter];
64               $ue_cs_rua_status_t=$ue_cs_rua_status[$iter];
65               $ue_cs_ranap_status_t=$ue_cs_ranap_status[$iter];
66               $ue_ps_rua_status_t=$ue_ps_rua_status[$iter];
67               $ue_ps_ranap_status_t=$ue_ps_ranap_status[$iter];
68               echo "<p>";
69               echo "<span title='plmn:10587 ci:bc75000 rnc_id:c70b000 &#13; lac:d030 rac:0 sac:1'>
70                     hnb[$iter] ip: [$hnb_ip[$iter]] </span>";
71               echo "</p>";
72
73               echo "<table border='1px' bordercolor='#000000' cellspacing='0px' style='border-collapse:collapse'>";
74
75               echo "<tr>";
76               echo "<th rowspan='2'> ID </th>";
77               echo "<th rowspan='2'> Context ID </th>";
78               echo "<th colspan='2'> CS </th>";
79               echo "<th colspan='2'> PS </th>";
80               echo "</tr>";
81
82               echo "<tr>";
83               echo "<th> RUA status </th>";
84               echo "<th> RANAP status </th>";
85               echo "<th> RUA status </th>";
86               echo "<th> RANAP status </th>";
87               echo "</tr>";
88               
89               for($i=0;$i<$ue_num;$i++){
90                     echo "<tr>";
91                     echo "<td>$ue_id_t[$i]</td>";
92                     echo "<td>$ue_context_id_t[$i]</td>";
93                     echo "<td>$ue_cs_rua_status_t[$i]</td>";
94                     echo "<td>$ue_cs_ranap_status_t[$i]</td>";
95                     echo "<td>$ue_ps_rua_status_t[$i]</td>";
96                     echo "<td>$ue_ps_ranap_status_t[$i]</td>";
97                     echo "</tr>";
98
99               }   
100               echo "</table>";
101             }
102             echo "<p>";
103             echo "<select name='hnb'>";
104             for($iter=0;$iter<$hnb_num;$iter++){
105               echo "<option>$hnb_ip[$iter]</option>";
106             }
107             echo "</select>";
108             echo "<select name='ue'>";
109             for($iter=0;$iter<$hnb_num;$iter++){
110               $ue_id_t=$ue_id[$iter];
111               for($i=0;$i<$ue_num;$i++){
112                     echo "<option>$ue_id_t[$i]";
113               }
114             }
115             echo "</select>";
116             echo "<select name='action'>
117               <option>deregister</option>
118               <option>reset</option>
119               <option>call</option>
120               <option>disconnect</option>
121               <option>paging</option>
122               <option>send sms</option>
123               <option>disregister</option>
124               </select>
125               <input type='submit' value='go'></input>
126               ";
127             echo "</form>";
128             echo "</p>";
129             echo "<form name='form2' method='post' action='index.php'>";
130             echo "<input type='submit' value='reload'></input>";
131             echo "</form>";
132 ?>
133 </html>
  
页: [1]
查看完整版本: php动态创建表单