如何在编辑时回显单选按钮的值

时间:2018-03-02 03:21:30

标签: php mysql checkbox radio-button sql-update

我之前已经问过这个问题。但我尝试了所有仍然无法获得输出的解决方案。这就是我所做的: - (实际上是我的更新页面中的问题)和问题只是单选按钮,我只想要单选按钮来携带值并使用数据库中的值检查它

update_page.php

<?php
include("config.php");
$item_code= $_GET['item_code'];
$sel = mysql_query("select * from `table 14` where Item_Code='$item_code'");
$get_sel = mysql_fetch_array($sel); ?>
<script type="text/javascript" LANGUAGE="JavaScript">
function getting()
{
var agree=confirm("Confirm Update?");
if (agree)
document.myform2.submit2();

else
return false;
}
</script>
<center>
<h2 class="back" width='1400px'>Update Item Info</h2>

<div class="content">
<p style="margin-top:20px; font-size:20px;"><b><?php echo 
$get_sel['Item_Code']; ?></b></p>
<br />

<div id="main">

<form name="myform2" action="admin_update_process.php?item_code=<?php echo 
$get_sel['Item_Code'];?>" method="POST" >
<table>

<tr>
    <th>Vendor</th>     
    <th>Vendor Desc</th>
    <th>Item Code</th>
    <th>Item Decs</th>
</tr>

<tr>
<td><input autofocus type="text" required name="vendor" 
class="input_teks_upd" size="30px" value='<?php echo $get_sel['Vendor']; ?>' 
/></td>
<td><input autofocus type="text" required name="vendor_desc" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Vendor_Desc']; ?>' /></td>
<td><input autofocus type="text" required name="item_code" 
class="input_teks_upd" size="30px" value='<?php echo $get_sel['Item_Code']; 
?
>' /></td>
<td><input autofocus type="text" required name="item_desc" 
class="input_teks_upd" size="30px" value='<?php echo $get_sel['Item_Desc']; 
?
 >' /></td>
<tr>
    <th>CUR</th>
    <th>Price</th>
    <th>COO</th>
    <th>COO Material</th>
</tr>
<tr>
<td><input autofocus type="text" required name="cur" class="input_teks_upd" 
size="30px" value='<?php echo $get_sel['Cur']; ?>' /></td>
<td><input autofocus type="text" required name="price" 
class="input_teks_upd" size="30px" value='<?php echo $get_sel['Price']; ?>' 
/></td>
<td><input autofocus type="text" required name="coo" class="input_teks_upd" 
size="30px" value='<?php echo $get_sel['Coo']; ?>' /></td>
<td><input autofocus type="text" required name="coo_material" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Coo_Material']; ?>' /></td>
</tr>
<tr>
    <th>PROD L/Time</th>
    <th>MOQ</th>
    <th>Part name/Material</th>
    <th>Normal Shipping Mode</th>
</tr>
<tr>
<td><input autofocus type="text" required name="prod_l_time" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Prod_L_Time']; ?>' /></td>
<td><input autofocus type="text" required name="moq" class="input_teks_upd" 
size="30px" value='<?php echo $get_sel['Moq']; ?>' /></td>
<td><input autofocus type="text" required name="part_name" 
class="input_teks_upd" size="30px" value='<?php echo $get_sel['Part_Name']; 
?
>' /></td>
<td><input autofocus type="text" required name="normal_shipping" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Normal_Shipping']; ?>' /></td>
<tr>
    <th>Shipping Lead Time</th>
    <th>Common/Customize for Onkyo</th>
    <th>Marker Part No</th>
    <th>Aprroval Spec (YES/NO)</th>
</tr>

<tr>
<td><input autofocus type="text" required name="ship_lead" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Shipping_Lead']; ?>' /></td>
<td><input autofocus type="text" required name="common" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Common_Customize']; ?>' /></td>
<td><input autofocus type="text" required name="maker_part" 
class="input_teks_upd" size="30px" value='<?php echo 
$get_sel['Maker_Part_No']; ?>' /></td>
<td><input autofocus type="radio" name="approval" value="YES" 
    <?php echo ($approval=='YES') ? " checked " : "";?>> YES
    <input autofocus type="radio" name="Green_Document" value="NO"
    <?php echo($approval=='NO') ? " checked " : "";?>>NO <br/>
</td>
    <th>Green Document (YES/NO)</th>
    <th>Upload Approval Spec</th>
    <th>Upload Green Document</th>
</tr>
<tr>
 <td><input autofocus type="radio" name="Green_Document" value="YES" 
    <?php echo ($Green_Document=='YES') ? " checked " : "";?>> YES
    <input autofocus type="radio" name="Green_Document" value="NO"
    <?php echo($Green_Document=='NO') ? " checked " : "";?>>NO <br/>
</td>
<td><input  type="file" name="file_approval"/></td>
<td><input  type="file" name="file_green"/></td>
</tr>
</table>
<br>
<input type="submit" name="submit2" value="Confirm Update Data" 
class="admin_button" onClick="return getting();" />

</form>


</div>
</div>  

</center>

update_query.php

<?php
include("config.php");

if (isset($_POST['submit2']))
{
extract($_POST);

$item_code=$_GET['item_code'];

if($item_code==''){

echo "<script type='text/javascript'>";
echo "alert('No details entered. Update Fail.')";
echo "</script>";
echo "<meta http-equiv='refresh' content='0; 
url=".$_SERVER['HTTP_REFERER']."'>";

}
else{
$pro1 = mysql_query("update `table 14` set Vendor='$vendor',Vendor_Desc='$vendor_desc',Item_Code='$item_code',Item_Desc='$item_desc', Cur='$cur', Price='$price', Coo='$coo', Coo_Material='$coo_material', Prod_L_Time ='$prod_l_time', 
Moq='$moq', Part_Name='$part_name', Normal_Shipping='$normal_shipping', Shipping_Lead='$ship_lead', Common_Customize='$common',
Maker_Part_No='$maker_part', Approval_Spec='$approval', Green_Document='$Green_Document' where Item_Code = '$item_code'"); //this the part I send the green_document

if($pro1)
    {
echo "<script type='text/javascript'>";
echo "alert('Item Info Successfully Updated')";
echo "</script>";
echo "<meta http-equiv='refresh' content='0; url=".$_SERVER['HTTP_REFERER']."'>";
}

else
{

echo "<script type='text/javascript'>";
echo "alert('Failed to update, try again')";
echo "</script>";
echo "<meta http-equiv='refresh' content='0; 
url=".$_SERVER['HTTP_REFERER']."'>";
}
}
}
mysql_close()       

1 个答案:

答案 0 :(得分:-1)

你快到了。看看这个,我只是对你的代码做了一些调整,包括回显test_str=""" list {values1} list \t{values2} """ def test_format(values): values1 = ",".join(values) values2 = ",\n\t".join(values) return test_str.format(values1=values1, values2=values2) print test_format(["1", "2", "3"]) 属性

&#13;
&#13;
checked
&#13;
&#13;
&#13;