XAMPP 1.7.7 [PHP:5.3.8]、MYSQL Serverバージョン:5.5.16、WebサーバーApache / 2.2.21、phpMyAdminバージョン情報:3.4.5を使用しています。
ユーザーがカウント(私のアプリケーションによると「Number_of_Bidders_Participated」)を入力し、複数のクライアントレコードを入力するための複数のフォームを(動的に)表示するようなアプリケーションを生成しようとしています。その後、PHPを使用してすべてのレコード値をフェッチし、テーブルに列を動的に作成して、その中に値を挿入します。
例:user type count( "Number_of_Bidders_Participated")value = 3次に、クライアント情報を更新するための3つのフォームを表示します。私はJavaScriptの助けを借りてそれを行いました。
私はそのために以下のコードを使用しています:
<!-- Basic code-->
Number of Bidders Participated:
<input name="no_of_bidders_participated" id="no_of_bidders_participated" type="text" style="vertical-align: middle;" />
<input type="button" onclick="increment_value()" value="Add Bidders info" />
<div id="container">
</div>
<script type="text/javascript">
var counter = 0;
function increment_value(chk)
{
var get = $("#no_of_bidders_participated").val();
if (counter > 0)
{
return;
}
else
{
counter++;
for(i=1; i<=get; i++)
{
$('#container').append('<br>Bidder '+ i +' Name: <input id="biddername'+ i +'" type="text" value=""/> Bidder'+ i +' Address: <input id="bidderadd'+ i +'" type="text" value=""/> Bidder'+ i +' Phone Number: <input id="bidderphone '+ i +'" type="text" value=""/><br><br> Bidder'+ i +' Email ID: <input id="bidderemail'+ i +'" type="text" value=""/> Bidder'+ i +' Cotted Amount: <input id="biddercotted_amount'+ i +'" type="text" value=""/> Bidder'+ i +' Tender Awarded: <select id="biddertender_awarded'+ i +'"><option value="No">No</option><option value="Yes">Yes</option></select><br><br><br>');
}
}
}
</script>
写真1に、このプロセスの出力を示します。ここでは、別のphpファイルにデータをフェッチするために割り当てid="biddername'+ i +'"
ています。しかし、以下のコードを使用すると、適切な結果が得られません。
${"biddername" . $i} = $_POST['biddername'.$i];
以下のエラーを示しています。
Notice: Undefined index: biddername1 in C:\xampp\htdocs\tender_monitoring_system\add_participated_bidders_info_submit.php on line 15
以下の出力を取得するために私を助けてください。また、MySQLサーバーで列を動的に作成するのを手伝ってください。
完全なコード:メールファイル
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>.::Tender Monitoring System::.</title>
<link rel="stylesheet" href="application.css" type="text/css" />
<script type="text/javascript" src="date/jquery-latest.js"></script>
<script type="text/javascript">
var counter = 0;
function increment_value(chk)
{
var get = $("#no_of_bidders_participated").val();
if (counter > 0)
{
return;
}
else
{
counter++;
for(i=1; i<=get; i++)
{
$('#container').append('<br>Bidder '+ i +' Name: <input id="biddername'+ i +'" type="text" value=""/> Bidder'+ i +' Address: <input id="bidderadd'+ i +'" type="text" value=""/> Bidder'+ i +' Phone Number: <input id="bidderphone '+ i +'" type="text" value=""/><br><br> Bidder'+ i +' Email ID: <input id="bidderemail'+ i +'" type="text" value=""/> Bidder'+ i +' Cotted Amount: <input id="biddercotted_amount'+ i +'" type="text" value=""/> Bidder'+ i +' Tender Awarded: <select id="biddertender_awarded'+ i +'"><option value="No">No</option><option value="Yes">Yes</option></select><br><br><br>');
}
}
}
</script>
</head>
<body>
<a href="http://localhost/tender_monitoring_system/"><img align="right" width="100px" height="40px" src="home.gif" alt="Home" /></a>
<a href="http://localhost/tender_monitoring_system/add_participated_bidders_information.php"><img align="right" width="100px" height="40px" src="back.gif" alt="Back" /></a>
<div id="heading"><br><h1>Tender Monitoring System</h1><h3>Tender Status</h3><br>
</div>
<?php
$txtSearch = $_POST['txtSearch'];
require('db_connect.php');
// The form has been submitted, query results
if ($txtSearch!='none')
{
?>
<center><br><br>
<form id="search_form" name="search_form" action="submit.php" method="post">
<?php
$queryitem = "SELECT tender_status,tender_number FROM tender WHERE tender_number='$txtSearch'";
// Execute the query
$result = mysql_query($queryitem);
?><b>
Tender Number :
<select name="qtender_number" id="qtender_number" disabled="disabled">
<?php
while($row = mysql_fetch_array($result))
{
$getvalue_number=$row["tender_number"]; //$getvalue_status has old tender_number value ramesh
?>
<option value="<?php echo $row['tender_number'] ?>"><?php echo $row['tender_number'] ?></option>
<?php
}
?>
</select>
<input type="hidden" name="getvalue_number" value="<?php echo $getvalue_number ?>"> <?php //for passing variable value to another file?>
<?php
$queryitem = "SELECT tender_status FROM tender WHERE tender_number='$txtSearch'";
// Execute the query
$result = mysql_query($queryitem);
?><b>
Tender Call:
<select name="call" id="call">
<option selected="selected" label="none" value="none">- - Select Tender Call - -</option>
<option value="1st Call">1st Call</option>
<option value="2nd Call">2nd Call</option>
<option value="3rd Call">3rd Call</option>
<option value="4th Call">4th Call</option>
<option value="5th Call">5th Call</option>
<option value="6th Call">6th Call</option>
<option value="7th Call">7th Call</option>
<option value="8th Call">8th Call</option>
<option value="9th Call">9th Call</option>
<option value="10th Call">10th Call</option>
</select><b><br><br>
Tender Status:
<select name="tender_status" id="tender_status">
<option selected="selected" label="none" value="none">- - Select Tender Status - -</option>
<option value="AA Received">AA Received</option>
<option value="NIT Awaited">NIT Awaited</option>
<option value="NIT Received">NIT Received</option>
<option value="Online Tender">Online Tender</option>
<option value="Locked Tender">Locked Tender</option>
<option value="Opened Tender">Opened Tender</option>
<option value="Online Technical Opened">Online Technical Opened</option>
<option value="Online Financial Opened">Online Financial Opened</option>
<option value="Sanctioned For Award">Sanctioned For Award</option>
<option value="Rejected Tender">Rejected Tender</option>
<option value="Recalled Tender">Recalled Tender</option>
</select>
Number of Bidders Participated:
<input name="no_of_bidders_participated" id="no_of_bidders_participated" type="text" style="vertical-align: middle;" />
<input type="button" onclick="increment_value()" value="Add Bidders info" />
<div id="container">
</div>
<br><br>
<input id="submit" type="submit" value="Submit" />
</form>
<?php
}
?>
</body>
</html>
submit.phpファイル
<?php
//$qtender_number = $_POST['qtender_number'];
$getvalue_number = $_POST['getvalue_number'];
$tender_call = $_POST['call'];
$getvalue_status = $_POST['tender_status'];
$no_of_bidders = $_POST['no_of_bidders_participated'];
echo $getvalue_number; //working
echo $tender_call;
echo $getvalue_status;
echo $no_of_bidders;
for($i=1; $i<=$no_of_bidders; $i++)
{
${"biddername" . $i} = $_POST['biddername'.$i]; //problem here..
echo ${"biddername" . $i};
}
?>