PHPで複数の選択クエリから複数の変数値を設定する方法. ここにphpコード(trans.php)があります
<?php
include('config.inc');
$pname = $_POST['pname'];
$usrname = $_POST['usrname'];
$iname = $_POST['iname'];
$udec = $_POST['udec'];
$usize = $_POST['usize'];
$qty = $_POST['qty'];
$lname = $_POST['lname'];
$p_id = mysql_result(mysql_query("SELECT `id` FROM `project_master` WHERE ( `Project_Code` = '" . $_POST['pname'] . "') "),0);
$user_id = mysql_result(mysql_query("SELECT `u_id` FROM `user` WHERE ( `user_name` = '" . $_POST['usrname']. "') "),0);
$i_id = mysql_result(mysql_query("SELECT `id` FROM `item_master` WHERE ( `item_name` = '" . $_POST['iname'] . "') "),0);
$unit_id = mysql_result(mysql_query("SELECT `id` FROM `unit_mstr` WHERE( `Unit_Name` = '" . $_POST['udec'] . "') "),0);
$loc_id = mysql_result(mysql_query("SELECT `id` FROM `location_mstr` WHERE( `l_name` = '" . $_POST['lname'] . "') "),0);
$sql= " INSERT INTO project_transaction_header(project_id, u_id, item_Id, unit_id,Size, Qty, location_id, Created_On, Created_By, Modified_on, Modified_By) VALUES ('$p_id','$user_id','$i_id',$unit_id','$item_size','$item_qty','$loc_id',now(),'system',now(),'system');";
しかし、私はエラーが発生しました
Notice: Undefined index: usrname in C:\xampp\htdocs\alogin\ptrans.php on line 14
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 6
Notice: Undefined index: iname in ..\..\ptrans.php on line 15
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 7
Notice: Undefined index: udec in ..\..\ptrans.php on line 16
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 8
Notice: Undefined index: lname in ..\..\ptrans.php on line 17
postメソッドを介してhtmlページから値を受け取ります..
これが私のHTMLコードで、そのPHP Transition.htmlを呼び出します
<HTML>
<head>
</head>
<body>
<div id="loginAdmin" class="animate form" >
<form class="cbp-mc-form" action="ptrans.php" id="trans" method="post" >
<div class="cbp-mc-column">
<p><label>Project Name:</label> <input name="pname"id="pname" type="text" autocomplete="off"></p>
  
<p><label>User Name:</label> <input id="usrname" name="usrname"type="text" autocomplete="off"></p>
  
<p><label>Itme Name:</label> <input id="iname" name="iname" type="text" autocomplete="off"></p>
</div>
<div class="cbp-mc-column">
<p><label>Unit Dec:</label> <input id="udec" name="udec" type="text" autocomplete="off"></p>
  
<p><label>Size:</label> <input id="usize" name="usize" type="text" autocomplete="off"></p>
  
<p><label>QTY:</label> <input id="qty" name="qty" type="text" autocomplete="off"></p>
</div>
<div class="cbp-mc-column">
<p><label>Location Name:</label> <input name="lname" id="lname" type="text" autocomplete="off"></p>
</div>
<div style="margin-top: 530px;"class="cbp-mc-submit-wrap"><input class="cbp-mc-submit" type="submit" value="SUBMIT" />
<input class="cbp-mc-submit" type="reset" name="reset" id="reset" value="Reset" />
</div>
</form>
</div>
</body>
</html>