截圖畫面更新的行不工作,保存按鈕複製行
注意:未定義指數:cur_id1在C:\ Program Files文件 (x86)的\ APACHE2.2 \ htdocs中\ hr \ setup \ manage_position_sub.php on line 87
警告:mssql_query()[function.mssql-query]:message:關鍵字'and'附近的語法錯誤 。 (嚴重性15)在C:\ Program Files (x86)\ Apache2.2 \ htdocs \ hr \ includes \ connecto.php on line 15
警告:mssql_query()[function.mssql-query]:查詢失敗在 C:\程序文件(x86)\ APACHE2.2 \ htdocs中\小時\包括關於 線\ connecto.php 15
說明:未定義指數:cur_id1在C:\ Program Files文件 (86)\的Apache2 .2 \ htdocs \ hr \ setup \ manage_position_sub.php on line 89
Warning:mssql_query()[function.mssql-query]:message:關鍵字'and'附近的語法錯誤 。 (嚴重性15)在C:\ Program Files (x86)\ Apache2.2 \ htdocs \ hr \ includes \ connecto.php on line 15
警告:mssql_query()[function.mssql-query]:查詢失敗在 C:\程序文件(x86)\ APACHE2.2 \ htdocs中\小時\包括關於 線\ connecto.php 15
說明:未定義指數:cur_id1在C:\ Program Files文件 (86)\的Apache2 .2在線92上的\ htdocs \ hr \ setup \ manage_position_sub.php
警告:mssql_query()[function.mssql-query]:消息:關鍵字'and'附近的語法不正確 。 (嚴重性15)在C:\ Program Files (x86)\ Apache2.2 \ htdocs \ hr \ includes \ connecto.php on line 15
警告:mssql_query()[function.mssql-query]:查詢失敗在 C:\程序文件(x86)\ APACHE2.2 \ htdocs中\小時\包括關於 線\ connecto.php 15
說明:未定義指數:cur_id1在C:\ Program Files文件 (86)\的Apache2 0.2 \ htdocs中\上線94
小時\設置\ manage_position_sub.php警告:mssql_query()[function.mssql-查詢]:消息:關鍵字 '和' 近不正確 語法。 (嚴重性15)在C:\ Program Files (x86)\ Apache2.2 \ htdocs \ hr \ includes \ connecto.php on line 15
警告:mssql_query()[function.mssql-query]:查詢失敗在 C:\程序文件(x86)\ APACHE2.2 \ htdocs中\小時\包括關於 線\ connecto.php 15
說明:未定義指數:cur_id1在C:\ Program Files文件 (86)\的Apache2 .2 \ htdocs \ hr \ setup \ manage_position_sub.php on line 96
現在的問題是,當我點擊保存按鈕更新查詢它只是複製最後一次行。插入時沒有問題。 php
代碼如下所示。如果需要,我會發布完整的代碼,任何熟悉php
和mysql
的人請通過它檢查。希望你們理解這個問題。請通過它檢查。
<?php
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<?php
header("Content-Type: text/html;charset=windows-1256");
include_once('../includes/header_config.php');
$sorting=' order by depe asc';
if (isset($_POST['field']))
{
if ($_POST['field'] != '')
{
$sorting=' order by '.$_POST['field'];
}
else
{
$sorting=' ';
}
}
?>
<?php
//delete
if(isset($_POST['action']) && ($_POST['action']==3)) {
$sql="delete from hr_position where code=".$_POST['delid'];
$qry = DB_query($sql,$db);
$sql="delete from listsvalues where listid=40 and id=".$_POST['delid'];
$qry = DB_query($sql,$db);
$sql = "delete from hrnodes where contactid = '".$_POST['delid']."' and userid=15";
$result2= DB_query($sql,$db);
}
?>
<?php
//insert
if(isset($_POST['action']) && ($_POST['action']==2)) {
if ($_POST['invoicebreakdown']=='' || $_POST['invoicebreakdown']==0) $invoice_breakdown = 1; else $invoice_breakdown = $_POST['invoicebreakdown'];
for ($i = 1; $i <= $invoice_breakdown; $i++){
if (isset($_POST['field1'.$i])) {
if(isset($_POST['cur_id_'.$i]) && $_POST['cur_id_'.$i]!='') $cur_id = $_POST['cur_id_'.$i]; else $cur_id ='';
if($cur_id=='') {
$sql="select max(code) as mx from hr_position";
$qry = DB_query($sql,$db);
if ($res = DB_fetch_array($qry))
{
if ($res['mx']==NULL)
{
$newid= 1;
}
else
{
$i =(int) $res['mx'];
$i=++$i;
$newid= $i;
}
}
echo $sql = "insert into hr_position (code,descr,lang) values (".$newid.",'".$_POST['field1'.$i]."',0)";
$result= DB_query($sql,$db);
echo $sql = "insert into listsvalues (id,listid,userid,descr,lang,seq) values (".$newid.",40,-1,'".$_POST['field1'.$i]."',0,".$newid.")";
$result= DB_query($sql,$db);
echo $sql = "insert into hr_position (code,descr,lang) values (".$newid.",'".$_POST['field2'.$i]."',1)";
$result= DB_query($sql,$db);
echo $sql = "insert into listsvalues (id,listid,userid,descr,lang,seq) values (".$newid.",40,-1,'".$_POST['field2'.$i]."',2,".$newid.")";
$result= DB_query($sql,$db);
echo $sql = "insert into hr_position (code,descr,lang) values (".$newid.",'".$_POST['field3'.$i]."',2)";
$result= DB_query($sql,$db);
echo $sql = "insert into listsvalues (id,listid,userid,descr,lang,seq) values (".$newid.",40,-1,'".$_POST['field3'.$i]."',1,".$newid.")";
$result= DB_query($sql,$db);
$sql = "select max(id) as mx from hrnodes ";
$result1= DB_query($sql,$db);
$newid1 = DB_fetch_array($result1);
$nwd = $newid1['mx']+1;
if ($_SESSION['lang']==0) {$name = $_POST['field1'.$i];} else if ($_SESSION['lang']==1) {$name = $_POST['field2'.$i];} else {$name = $_POST['field3'.$i];}
$sql = "insert into hrnodes (id,userid,title,position,parentid,contactid,acyear) VALUES
('".$nwd."','15','".$name."','0','2','".$newid."','')";
$result2= DB_query($sql,$db);
}
else
{
$sql = "update hr_position set descr='".$_POST['field1'.$i]."' where code =".$_POST['cur_id'.$i]." and lang = 0";
$result= DB_query($sql,$db);
$sql = "update listsvalues set descr='".$_POST['field1'.$i]."' where listid=40 and id =".$_POST['cur_id'.$i]." and lang = 0";
$result= DB_query($sql,$db);
$sql = "update hr_position set descr='".$_POST['field2'.$i]."' where code =".$_POST['cur_id'.$i]." and lang = 2";
$result= DB_query($sql,$db);
$sql = "update listsvalues set descr='".$_POST['field2'.$i]."' where listid=40 and id =".$_POST['cur_id'.$i]." and lang = 2";
$result= DB_query($sql,$db);
$sql = "update hr_position set descr='".$_POST['field3'.$i]."' where code =".$_POST['cur_id'.$i]." and lang = 1";
$result= DB_query($sql,$db);
$sql = "update listsvalues set descr='".$_POST['field3'.$i]."' where listid=40 and id =".$_POST['cur_id'.$i]." and lang = 1";
$result= DB_query($sql,$db);
if ($_SESSION['lang']==0) {$name = $_POST['field1'.$i];} else if ($_SESSION['lang']==1) {$name = $_POST['field2'.$i];} else {$name = $_POST['field3'.$i];}
$sql = "update hrnodes set title='".$name."' where contactid = '".$_POST['cur_id'.$i]."' and userid=15";
$result2= DB_query($sql,$db);
}
}
}
}
?>
<?php
if(!isset($_POST['breakdown'])) $_POST['breakdown']=0;
$sql = "SELECT distinct hr_position.code, hr_position.descr AS depe, hr_position_1.descr AS depf, hr_position_2.descr AS depa
FROM hr_position INNER JOIN
hr_position hr_position_1 ON hr_position.code = hr_position_1.code INNER JOIN
hr_position hr_position_2 ON hr_position_1.code = hr_position_2.code
WHERE hr_position.code<>-1 and (hr_position.lang = 0) AND (hr_position_2.lang = 2) AND (hr_position_1.lang = 1)".$sorting;
$result= DB_query($sql,$db);
$num_rows = DB_num_rows($result);
$tot = $_POST['breakdown']+$num_rows;
?>
<input type="hidden" name="amttype" value="" id="amttype">
<input type="hidden" name="invoicebreakdown" value="<?php echo $tot;?>" id="invoicebreakdown">
<input type="hidden" name="subbreakdown" value="" id="subbreakdown">
<table width="95%" border="0" cellpadding="5" cellspacing="0" class="table_fullwidth">
<tr><th width="30%">Position</th><th width="33%">Position</th>
<th width="32%">ÇÇáãÑßÒ</th>
</tr>
<?php $i=1;
while ($myrow1 = DB_fetch_array($result)) {
if ($i % 2==0) $bkg='td1'; else $bkg='td2';
?>
<tr id="trow_<?php echo $i;?>" class="<?php echo $bkg;?> ">
<td align="center"><input type="hidden" name="cur_id_<?php echo $i;?>" id="cur_id_<?php echo $i;?>" value="<?php echo $myrow1['code'];?>"> <input type="text" name="field1<?php echo $i;?>" id="field1<?php echo $i;?>" class="sel_long1 required" value="<?php echo $myrow1['depe'];?>" tabindex="<?php echo $i;?>_1" > </td>
<td align="center"><input tabindex="<?php echo $i;?>_2" class="sel_long1 required" type="text" name="field2<?php echo $i;?>" id="field2<?php echo $i;?>" value="<?php echo $myrow1['depf'] ;?>"> </td>
<td align="center"><input tabindex="<?php echo $i;?>_4" class="sel_long1" type="text" name="field3<?php echo $i;?>" id="field3_<?php echo $i;?>" value="<?php echo $myrow1['depa'] ;?>"> </td>
<td align="center"> <img src="<?php echo $site_path;?>images/del.png" width="20" class="cur" title="Delete" onclick="deleteitem('<?php echo $myrow1['code'];?>');"></td>
</tr>
<?php
$i++;
}
$breakdown = $_POST['breakdown']+$num_rows;
$j=$num_rows+1;
while($j<=$breakdown) {
if ($j % 2==0) $bkg='td1'; else $bkg='td2';
?>
<tr id="trow_<?php echo $j;?>" class="<?php echo $bkg;?> "><td align="center"><input type="hidden" name="cur_id_<?php echo $j;?>" id="cur_id_<?php echo $j;?>" value="">
<input type="text" name="field1<?php echo $j;?>" id="field1<?php echo $j;?>" class="sel_long1 required" value="" tabindex="<?php echo $j;?>_1" > </td>
<td align="center" ><input class="sel_long1 required" type="text" name="field2<?php echo $j;?>" id="field2<?php echo $j;?>" value="" tabindex="<?php echo $j;?>_2"></td>
<td align="center"><input class="sel_long1 required" type="text" name="field3<?php echo $j;?>" id="field3<?php echo $j;?>" value="" tabindex="<?php echo $j;?>_4"> </td>
<td align="center"><img src="<?php echo $site_path;?>images/del.png" title="Delete" onclick="delete_row_details(<?php echo $j;?>)" width="20" class="cur"></td>
</tr>
<?php $j++; }?>
</table>
<div class="save_bt"><input name="save" id="savebt" class="no_marright submit-green save_right" value="Save" type="button" onclick="validate_save()" tabindex="<?php echo $j;?>"> </div>
<div id="did1"></div>
<script>
var $targets = $('#erp_from_sub').find('input, button , select'),
steps = $targets.map(function() {
return $(this).attr('tabindex');
}).get();
$('#erp_from_sub').on('keypress', 'input, button, select', function(e) {
if (e.keyCode == 13) {
var current = $.inArray($(this).attr('tabindex'), steps),
next = steps[++current % steps.length];
$targets.filter('[tabindex="' + next + '"]').focus();
}
});
function deleteitem(a) {
if(confirm('Are you sure you want delete?')) { document.erp_from_sub.delid.value=a; document.getElementById('action').value='3';load_subpage('erp_from_sub');}
}
function delete_row_details(id)
{
var el = document.getElementById('trow_'+id);
if(confirm("Are you sure you want to delete this row")==true)
el.parentNode.removeChild(el);
/*calculateSum_credit();*/
}
</script>
不使用大寫字! ..這就像在網絡中尖叫.. – scaisEdge
清楚它插入或更新取決於$ cur_id的值。所以你需要調試發送給服務器的那個值。據推測,它總是空的,當它不應該。如果您無法弄清楚,請在此處發佈HTML表單,然後嘗試發送該值。順便說一句,這段代碼非常容易受到SQL注入攻擊。您應該學會使用參數化查詢和準備語句。 – ADyson
好的..代碼更新@ADyson –