Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 编辑时如何回显单选按钮的值_Php_Mysql_Checkbox_Radio Button_Sql Update - Fatal编程技术网

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

Php 编辑时如何回显单选按钮的值,php,mysql,checkbox,radio-button,sql-update,Php,Mysql,Checkbox,Radio Button,Sql Update,我知道以前有人问过这个问题。但我尝试了所有的解决方案,仍然无法获得输出。这就是我所做的:-(实际上,问题就在我的更新页面中)问题就在单选按钮上,我只希望单选按钮携带值,并用数据库中的值进行检查 更新_page.php <?php include("config.php"); $item_code= $_GET['item_code']; $sel = mysql_query("select * from `table 14` where Item_Code='$item_code'");

我知道以前有人问过这个问题。但我尝试了所有的解决方案,仍然无法获得输出。这就是我所做的:-(实际上,问题就在我的更新页面中)问题就在单选按钮上,我只希望单选按钮携带值,并用数据库中的值进行检查

更新_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>

你就快到了。看看这个,我刚刚对你的代码做了一些调整,包括回显
checked
属性

绿色文件(是/否): 对 否

>否

if($green_document=='YES'){?>checked=“checked”您是否尝试了
if($green_document=='YES'){?>
@Naga是的,已经这样做了,但是仍然不能。你的实际问题还不清楚。你能提供一个你想要发生什么的例子吗?请解释一下。绿色文档从哪里来?为什么你有两套相同的收音机?流量是什么?你卡在哪里了?@NazirahAnwar哇,真的很难理解你r通过注释查看问题详细信息。请花时间通过编辑澄清您的问题。您是否需要输入标签上的
id
属性?您是否回显了
$green\u文档的值以确保其符合预期值?(请清除您的注释并更新您的问题)@令人难以置信的是,没有声明变量是正确的。请投票表决主题错误。不确定我为什么会出现此错误“分析错误:语法错误,意外'?” @jerome@IncredibleHat我试过了,但仍然无法获得输出。请有人帮助我。是的,我忘了删除
如果
。我已经编辑了答案,请check@NazirahAnwar我再次编辑了。Srry for inconvincience这一次我没有得到错误,但两个单选按钮都未选中@jerome
<?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()