我刚开始的
我的php
<?php
mysql_select_db("$db") or die(mysql_error());
$sql = "SELECT kpi FROM pin_kpi_types";
$query = mysql_query($sql);
echo '<select name="KPI" style="width: 400px">';
while ($row = mysql_fetch_assoc($query)) {
echo '<option>'.$row['KPI'].'</option>';
}
echo '</select>';
?>
我当前的标签/输入方法,需要我手动键入。
我要做的是从表中提取一个查询,以选择唯一可用的KPI类型。
现在开始工作了。
<p>
<label for="KPIType" id="preinput">Choose KPI Type: </label>
<input type="text" name="kpi_type" required placeholder="Lead" id="inputid" />
</p>
我以前在哪里
不幸的是,Lucky发布的答案并没有帮助我,但它指引了我正确的方向。
我现在有重复的字段吗?它不会将值发布到数据库中。或者。
这是一张截图。。。
http://s30.postimg.org/o1c2l9yr5/Untitled.png
有人能把我引向错误的方向吗?:)
提前谢谢你的帮助。
<?php
include('db.php');
$select=mysql_query("SELECT * FROM pin_kpi_types");
$i=1;
while( $userrow=mysql_fetch_array($select) )
{
$kpi_id =$userrow['KPI_ID'];
$kpi =$userrow['KPI'];
?>
<style>
#CreateStatusTypeFORM label {display: inline-block;width: 10em; text-align: right;padding-right: 0.5em;}
</style>
<div id="CreateStatusTypeFORM">
<form action="insert.php" method="post" name="insertform">
<p>
<div align='center'><label for="StatusColor" id="preinput">Choose A Color: </label>
<ui-colorpicker ng-model="targetColor"></ui-colorpicker></div>
<input type="hidden" name="pinstatus_color" value="{{targetColor}}" id="inputid" />
</p>
<p>
<label for="StatusName" id="preinput">Set Status Name: </label>
<input type="text" name="pinstatus_type" required placeholder="Come Back" id="inputid"/>
</p>
<p>
<label for="StatusName" id="preinput">Available KPI Types: </label>
<select name="<?php echo $kpi; ?>" style="width: 237px">
<option name="KPI" required id="inputid" value="<?php echo $kpi; ?>"><?php echo $kpi; ?></option>
</select>
</p>
<?php } ?>
<input type="submit" name="send" value="Submit" id="inputid1" />
</p>
</form>
我现在在哪
我就在这里。我现在不需要一遍又一遍地重复就可以把下拉菜单改对了。但是,现在我无法获取将实际选定的KPI发布到DB的值。其他所有内容都向数据库提交数据,但
KPI_type option.
<style>
.StatusForm {padding-left:75px;}
.CreateStatusTypeFORM {padding:25px;border-style:solid; border-color:solid black; width: 500px;background-color:#C4C4C4;}
#CreateStatusTypeFORM label {display: inline-block;width: 100em;}
#CreateStatusTypeFORM input {border-color:solid black;}
#CreateStatusTypeFORM input[type=text] {padding:5px; border:1px solid #666; -webkit-border-radius: 5px; border-radius: 5px;}
</style>
<div class='StatusForm'>
<div class="CreateStatusTypeFORM">
<H3> ADD New Status </H3>
<form action="insert.php" method="post" name="insertform">
<p>
<label for="StatusColor" id="preinput">Choose A Color: </label>
<ui-colorpicker ng-model="targetColor"></ui-colorpicker>
<input type="hidden" name="pinstatus_color" value="{{targetColor}}" id="inputid" required placeholder=""/>
</p>
<p>
<label for="StatusName" id="preinput">Set Status Name: </label>
<input type="text" name="pinstatus_type" required placeholder="" id="inputid"/>
</p>
<p>
<label for="KPI" id="preinput">Available KPI Types: </label>
<select>
<?php
include('db.php');
$select2=mysql_query("SELECT * FROM pin_kpi_types ORDER BY KPI_ID DESC");
while( $userrow=mysql_fetch_array($select2) )
{
$kpi =$userrow['KPI'];
$kpi_id =$userrow['KPI_ID'];
?>
<option name="kpi_type" required id="inputid" value="<?php echo $kpi; ?>"><?php echo $kpi; ?></option><?php } ?>
</select>
</p>
<input type="submit" name="send" value="Submit" id="inputid1" />
</p>
</form>
</div>
</div>
这是insert函数。
<?php
ob_start();
include("db.php");
if(isset($_POST['send'])!="")
{
$pinstatus_type =mysql_real_escape_string($_POST['pinstatus_type']);
$kpi_type =mysql_real_escape_string($_POST['kpi_type']);
$pinstatus_color =mysql_real_escape_string($_POST['pinstatus_color']);
$update =mysql_query("
INSERT INTO pin_status_types(
pinstatus_type,
kpi_type,
pinstatus_color,
created
)
VALUES(
'$pinstatus_type',
'$kpi_type',
'$pinstatus_color',
now()
)
");
if($update)
{
$msg="Successfully Updated!!";
echo "<script type='text/javascript'>alert('$msg');</script>";
header('Location:index.php');
}
else
{
$errormsg="Something went wrong, Try again";
echo "<script type='text/javascript'>alert('$errormsg');</script>";
}
}
ob_end_flush();
?>
最佳答案
mysql_select_db("$db") or die(mysql_error());
$sql = "SELECT kpi FROM pin_kpi_types";
$query = mysql_query($sql);
echo '<label for="KPIType" id="preinput">Choose KPI Type: </label>';
echo '<select name="KPI" style="width: 400px" required id="inputid">';
echo '<option value=''>Lead</option>';
while ($row = mysql_fetch_assoc($query)) {
echo '<option value='.$row['KPI'].'>'.$row['KPI'].'</option>';
}
echo '</select>';