我使用php insert进入Microsoft SQL表,下面是我的代码:
$server = "**/**,1433";
$connectionInfo = array( "Database"=>"***", "UID"=>"**", "PWD"=>"******" );
$conn = sqlsrv_connect( $server, $connectionInfo );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
$sql = "SELECT Item.HQID, Item.ItemLookupCode, Item.Description, Item.ExtendedDescription, Item.SalePrice, Item.Price, Item.CategoryID FROM Item WHERE Item.HQID = '$check'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
$html_table = '<table border="1" cellspacing="0" cellpadding="2">';
$html_table .= '<form method="post" action="upload.php"><tr><td width="350" align ="center">' .$row['Description']. '</td><td width="350" align ="center">' .$row['ExtendedDescription']. '</td><td width="130" align="center">'
.$row['ItemLookupCode']. '<td width="100" align="center">' .$row['SalePrice']. '</td><td width="100" align="center">' .$row['Price']. '</td><td width="200" align="center"><input
type="text" size="24" name="stitle"></td><td width="100" align="center"><input type="text" size="8" name="wprice"></td><td width="120" align="center"><input type="text" size="10" name="scategory"></td><td width="220" align="center"><input
type="text" size="28" name="sbody"></td></tr>';
$html_table .= '</table>';
echo $html_table;
}
}
}
}
?>
<input type="submit" value="Upload this page" ></form>
Run Code Online (Sandbox Code Playgroud)
我有一个<input>与name="stitle"我想的PHP代码,以从每个值<input>,但目前它拿起刚刚从第一个值<input>.我该如何解决?
你的帖子格式很糟糕,但我认为你正在寻找数组符号.
你可以做出类似的东西:
<input type="text" size="24" name="stitle[]">
Run Code Online (Sandbox Code Playgroud)
的$_POST阵列字段stitle是与提交表单之后的所有值的数组.