我有一个下拉列表,通过调用另一个PHP文件来填充,该文件的值来自数据库。功能有效但我希望在更改表单提交后保留选定的值。
我通过将以下内容用于静态列表取得了成功,但不确定如何使其适用于从数据库获取的动态列表
library(OpenMx)
diag2vec(cor(d1, d2, method = "kendall"))
以下是选择
的HTML代码<option value="company" <?php if($_GET['sort']== 'company') echo 'selected="selected"';?>>Company</option>
这是sql_clients.php代码的一部分
<select name="client" id="client" onChange='this.form.submit()'>
<option value="default"></option>
<option value="all">----- ALL CLIENTS -----</option>
<?php
include("sql_clients.php");
?>
由于
答案 0 :(得分:0)
同样的事情,就是现在而不是一个硬编码的值,使用变量:
public static void main(String[] args) {
// TODO code application logic here
int[] age = new int []{21,20,19,18,18,};
String name [] = {"sofia","maria","john","Petra","mark"};
int sum = 0;
int avg;
int min=age[0];
int i;
int counter=0;
for(i=0;i<age.length;i++){
if(age[i]<min ) {
min=age[i];
}
avg= sum/age.length;
System.out.println("the avarage of all Students are :"+avg);
System.out.println("the minimum age of all Students : "+min);
}
for(i=0;i<age.length;i++){
if (age[i] == min ) {
System.out.println("the minimum age of all Students : "+name[i]);
}
}
}
同样while( $row = sqlsrv_fetch_array($result))
{
echo '<option value="' .$row['CompanyName'] . '"';
if($_GET['sort']==$row['CompanyName'])
{
echo ' selected="selected"';
}
echo '>' . $row['CompanyName'] . "</option>" ."\n" ."\t" ."\t" ."\t" ."\t" ."\t";
}
应为$row[CompanyName]