我正在尝试制作一个测试表单(向导),并且在每一步(选项卡)上我都有来自$ step查询的所有行,而不仅仅是我需要的那些行。 db中的表看起来像这样
//main_steps
id_main_steps = 1...40
step_number = 5.[1..40]
//vpf_steps
step = 5.[1..40].[1..x]
//code
$main = mysql_query("select * from main_steps")or die(mysql_error());
while($row1 = mysql_fetch_array($main)){
echo "<div class=\"tab-pane\" id=\"tab5".$row1['id_main_steps']."\">".$row1['step_number']."-".$row1['step_measurement']."</div>";
$step = mysql_query("SELECT * FROM vpf_steps where step like '".$row1['step_number'].".%'")or die(mysql_error());
while($row2 = mysql_fetch_array($step)){
echo "
<div class=\"form-group\">
<div class=\"row\">
<div class=\"col-md-2\">".$row2['step']."</div>
<div class=\"col-md-4\">".$row2['measurement']."</div>
<div class=\"col-md-2\"><input type=\"".$row2['input_type']."\" class=\"form-control\" name=\"".$row2['step']."\"></div>
</div>
</div>";
}
}
UPDATE 表结构 主要步骤
id_main_steps | step_number | step_measurement
1 | 5.01 | main_step1
2 | 5.02 | main_step2
....
vpf_steps
id_vpf_steps | step | measurement
1 | 5.01.01 | step1_1
2 | 5.01.02 | step1_2
3 | 5.01.03 | step1_3
4 | 5.02.01 | step2_1
5 | 5.02.01 | step2_2
....
输出应该是这样的
on tab1
5.01 main_step1
5.01.01 step1_1
5.01.02 step1_2
5.01.03 step2_3
on tab2
5.02 main_step2
5.02.01 step2_1
5.02.01 step2_1
但我得到的是
on tab1
5.01 main_step1
5.01.01 step1_1
5.01.02 step1_2
5.01.03 step2_3
5.02.01 step2_1
5.02.01 step2_1
on tab2
5.01.01 step1_1
5.01.02 step1_2
5.01.03 step2_3
5.02 main_step2
5.02.01 step2_1
5.02.01 step2_1
答案 0 :(得分:0)
这解决了所有问题
{{1}}