У меня есть таблица с записями из sql srv.Я хочу создать динамическую форму, выбрать программу и опубликовать детали в файл test.php для получения всех выбранных переменных.
<?php
require_once('header.php');
require_once('sigmaconnect.php');
$tsql = "SELECT DISTINCT ProgramName,Rep, Round(Yeld,2) As Yeld, Count(PartName) As Parts,SUM(QtyNested) As TotalParts, MachineName, Material, DatePosting,TimePosting, Length, Width, Thickness, CuttingTime FROM dbo.RecivePrograms GROUP BY ProgramName,Rep, MachineName, Round(Yeld,2),DatePosting,TimePosting, Length, Width, Thickness, CuttingTime, Material";
$tsql2 = "SELECT count(DISTINCT ProgramName) As Prog FROM dbo.RecivePrograms";
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
$stmt2 = sqlsrv_query( $conn, $tsql2);
if ( $stmt )
{
//echo "Statement executed.<br>\n";
}
else
{
echo "Error in statement execution.\n";
die( print_r( sqlsrv_errors(), true));
}
?>
<script>
PNotify.notice({
title: 'Please wait',
text: "I'm try geting data from SigmaNest. It may take a while"
});
</script>
<title>[TS] Inranet :: Program Nesting</title>
<div class="content custom-scrollbar">
<div id="e-commerce-products" class="page-layout carded full-width">
<div class="top-bg bg-primary"></div>
<!-- CONTENT -->
<div class="page-content-wrapper">
<!-- HEADER -->
<div class="page-header light-fg row no-gutters align-items-center justify-content-between">
<!-- APP TITLE -->
<div class="col-12 col-sm">
<div class="logo row no-gutters justify-content-center align-items-start justify-content-sm-start">
<div class="logo-icon mr-3 mt-1">
<i class="icon-account-switch"></i>
</div>
<div class="logo-text">
<div class="h4">Program to nesting</div>
<div class="">Total Programs:
<?php
while( $row2 = sqlsrv_fetch_array($stmt2)) {
echo $row2['Prog'];
}
?>
</div>
</div>
</div>
</div>
<!-- / APP TITLE -->
<!-- SEARCH -->
<div class="col search-wrapper px-2">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-icon">
<i class="icon icon-magnify"></i>
</button>
</span>
<input id="products-search-input" type="text" class="form-control" placeholder="Search" aria-label="Search" />
</div>
</div>
<!-- / SEARCH -->
<div class="col-auto">
<!--<button id="add-file-button" type="submit" data-toggle="modal" data-dismiss="modal" data-backdrop="false" data-target="#add_new_user" class="btn btn-danger btn-fab fuse-ripple-ready" aria-label="Add file">
<i class="icon icon-plus"></i>
</button>-->
<form method="POST" action="test.php">
<button type="submit" class="btn btn-secondary">ASSIGN</button>
</div>
</div>
<!-- / HEADER -->
<div class="page-content-card">
<table id="e-commerce-products-table" class="table dataTable">
<thead>
<tr>
<th>
<div class="table-header">
<span class="column-title">Check</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Program Name</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Reperat</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Yeld</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Type Parts</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Total Parts</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Material</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Full size (TxLxW)</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Cutting Time</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Machine</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Date</span>
</div>
</th>
<th>
<div class="table-header">
<span class="column-title">Time</span>
</div>
</th>
</tr>
</thead>
<tbody>
<?php
while( $row = sqlsrv_fetch_array($stmt))
{
echo "<tr>";
echo "<td><input type='checkbox' name='".$row['ProgramName']."' value='".$row['ProgramName']."'></td>";
echo "<Td><a href='s_tonest_preview.php?pn=".$row['ProgramName']."'>".$row['ProgramName']."</a></td>";
echo "<Td>".$row['Rep']."</td>";
echo "<Td>";
if ($row['Yeld'] > 75) {
echo "<i class='icon icon-arrow-up text-green'></i>".$row['Yeld']."";
}
else
{
echo "<i class='icon icon-arrow-down text-red '></i>".$row['Yeld']."";
}
echo "</td>";
echo "<Td>".$row['Parts']."</td>";
echo "<Td>".$row['TotalParts']."</td>";
echo "<Td>".$row['Material']."</td>";
echo "<Td>".$row['Thickness']."x".$row['Length']."x".$row['Width']."</td>";
echo "<Td>".$row['CuttingTime']."</td>";
echo "<Td>".$row['MachineName']."</td>";
echo "<Td>".$row['DatePosting']."</td>";
echo "<Td>".$row['TimePosting']."</td>";
echo "</tr>";
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
</tbody>
</table>
</form>
</div>
</div>
<!-- / CONTENT -->
</div>
<script type="text/javascript" src="./assets/js/apps/tables/classic.js"></script>
</div>
<?php
require_once('footer.php');
?>
test.php
:
<?php
var_dump($_POST)
?>
Я не знаю, почему, когда я поставил флажок в то время как из запроса sql srv, я получаю только 0 вtest.php
, но если я поставлю этот флажок строки до или через некоторое время, эта переменная будет успешно опубликована.У вас есть идеи?