如何仅在备用输入字段行上显示数据? [英] How to display data only on alternate input field rows?

查看:81
本文介绍了如何仅在备用输入字段行上显示数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi I'm trying to display some data in a series of text boxes in a while loop. I want to fill the input fields based on a select option from the previous page. If the selected value is 25, then data should only be displayed in every fourth row. If it is 50, then data should be displayed in every alternate row, and for 100 percent, all the values will be displayed. I have marked the places where the condition of the selected value needs to be applied.







previous。 php




previous.php

<select class="form-control" name="select36">
<option value="100">100%</option>
<option value="50">50%</option>
<option value="25">25%</option>





add.php

  <?php
<!-- MYSQL QUERY -->
$sql = "select id ,code, addl_item_code_barcode, main_group, 
item_name_w_shade_category, shade_name, size , current_stock from items 
where main_group in (SELECT distinct(main_group) FROM items WHERE 
addl_item_code_barcode IN ($d)  and status='active') and status='active' 
order by  item_name_w_shade_category, size, shade_name";
$result = pg_query($db, $sql);
$counter = 1;
$i = 1;
while ($res = pg_fetch_assoc($result)) {

$i++;
?>    
<td> 
<!-- THIS IS WHERE THE CONDITION NEEDS TO BE APPLIED FOR  SELECTED VALUE-->
<?php

if(isset($_REQUEST['select36'])){

<!-- FOR 100% (DISPLAY DATA IN EVERY ROW)-->  
if($_REQUEST['select36'] == 100){ 

?>
<input type="text" class="form-control"  size ="1" name="p36"  value =<?php 
echo $balqty; ?> disabled> <br>
<?php
if (isset($_REQUEST['add1'])) {
$var1 = $_REQUEST['add1'];

if ($var1 > $balqty) {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1"   style="background-color: whitesmoke;"  size ="5" 
name="qty_1<?php echo $res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" 
value ="<?php echo $balqty ?>" onchange="calculateTotal()" readonly>
<?php } 

else {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1" maxlength="4" size ="5" name="qty_1<?php echo $res['id'] ?>" 
id="qty_1<?php echo $res['id'] ?>"  onchange="calculateTotal()"  value ="<? 
php echo $var1 ?>">
<?php
}
?>

<?php
} 

else {

 $var1 = 0;
 if ($var1 > $balqty) {
 ?>
 <input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1"  style="background-color: whitesmoke;"  size ="5" name="qty_1<? 
php echo $res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" value ="<?php 
echo $balqty; ?>" onchange="calculateTotal()"  readonly>
<?php }
 

else {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1" maxlength="4" min="0"  size ="5" name="qty_1<?php echo 
$res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" value ="<?php echo $var1 ? 
>" onchange="calculateTotal()"  readonly>
<?php
    }

  }

}
<!-- END FOR 100% (DISPLAY DATA IN EVERY ROW)--> 



<!-- WHAT I TRIED FOR 50% (DISPLAY DATA IN ALTERNATE ROWS) -->                                                  
elseif($_REQUEST['select36'] == 50){

if ($i%2==0) {
 ?>

<input type="text" class="form-control"  size ="1" name="p36"  value =<?php 
echo $balqty; ?> disabled> <br>
<?php

if (isset($_REQUEST['add1'])) {
$var1 = $_REQUEST['add1'];

if ($var1 > $balqty) {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1"   style="background-color: whitesmoke;"  size ="5" 
name="qty_1<?php echo $res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" 
value ="<?php echo $balqty ?>" onchange="calculateTotal()" readonly>
<?php } 


else {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1" maxlength="4" size ="5" name="qty_1<?php echo $res['id'] ?>" 
id="qty_1<?php echo $res['id'] ?>"  onchange="calculateTotal()"  value ="<? 
php echo $var1 ?>">
<?php
}

?>
<?php
} 

else {
$var1 = 0;

if ($var1 > $balqty) {
?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1"  style="background-color: whitesmoke;"  size ="5" name="qty_1<? 
php echo $res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" value ="<?php 
echo $balqty; ?>" onchange="calculateTotal()"  readonly>
                        <?php }

 else {
                            ?>
<input type="text" class="form-control check-change<?php echo $counter; ?> 
saisie add1" maxlength="4" min="0"  size ="5" name="qty_1<?php echo 
$res['id'] ?>" id="qty_1<?php echo $res['id'] ?>" value ="<?php echo $var1 ? 
>" onchange="calculateTotal()"  readonly>
<?php
   }

  }

 } <!--- END OF IF i%2==0 loop -->

}
<!-- END OF WHAT I TRIED FOR 50% (DISPLAY DATA IN ALTERNATE ROWS) -->  
}
?>
<!-- THIS IS WHERE THE CONDITION NEEDS TO END FOR THE SELECTED VALUE -->   
</td>  
<?php
$counter = $counter + 1;
}





我的尝试:



这就是它应该是什么样子





if(isset($ _ REQUEST ['select36'])) {

if($ _ REQUEST ['select36'] == 25){

显示每第4行的数据<! - 请使用此逻辑帮助我 - >

}

else if($ _ REQUEST ['select36'] == 50){

显示备用行中的数据
}

else if($ _ REQUEST ['select36'] == 100){

每行显示数据

}

}





请帮助纠正50%的逻辑并构建25%的逻辑。另外请记住,即使没有显示数据,也需要显示空文本框。任何帮助表示赞赏。谢谢!



What I have tried:

This is how it should look like


if(isset($_REQUEST['select36'])){
if($_REQUEST['select36'] == 25){
display data in every 4th row <!-- KINDLY HELP ME WITH THIS LOGIC -->
}
else if($_REQUEST['select36'] == 50){
display data in alternate row
}
else if($_REQUEST['select36'] == 100){
display data in every row
}
}


Kindly help correct the logic for 50% and also build the logic for 25%. Also kindly keep in mind that even if the data is not being displayed, empty textboxes need to be displayed. Any help is appreciated. Thanks!

推荐答案

sql =select item,$ b $ item $ in(SELECT distinct(main_group)FROM items WHERE
addl_item_code_barcode IN(
sql = "select id ,code, addl_item_code_barcode, main_group, item_name_w_shade_category, shade_name, size , current_stock from items where main_group in (SELECT distinct(main_group) FROM items WHERE addl_item_code_barcode IN (


d)和status ='active')和status ='active'
order by item_name_w_shade_category ,size,shade_name;
d) and status='active') and status='active' order by item_name_w_shade_category, size, shade_name";


result = pg_query(
result = pg_query(


这篇关于如何仅在备用输入字段行上显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆