 |
|
สอบถามหน่อยครับพอดีผมใช้ SELECT MAX(ID) FROM table_name เพื่อที่จะเอาไป insert อีกตารางอะครับพี่ แต่มัน errorNotice: Undefined index: ID ครับ แต่พอไป runใน mssql มันออกค่าmax มาให้อะครับผมผิดตรงไหนหรอครับ
อันนี้ code ครับพี่
Code (PHP)
include('condb/func.php');
$dblink = connect_db();
$str = "insert into testImage(name, image, note) values(?, ?, ?)";
$params = array('12345', '1234567', 'tserettrr');
$stmt = sqlsrv_query( $dblink, $str, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "Record add successfully";
}
$id="SELECT MAX('ID') FROM testImage";
$objQuery = sqlsrv_query($dblink, $id) or die ("Error Query [".$id."]");
$row = sqlsrv_fetch_array($objQuery, SQLSRV_FETCH_ASSOC);
echo $row['ID'];
Tag : PHP, Ms SQL Server 2012
|
|
 |
 |
 |
 |
Date :
2019-11-18 14:19:35 |
By :
erlnw001 |
View :
1243 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |