我已经创建了 php,并在 mysql 数据库中插入了 php 函数。我不确定如何使用数组来检查是否 >= 1 并显示错误消息。
我有commit.php
代码:
switch ( $_GET['action'] ) {
case "Insert":
$courseid = $_POST['courseid'];
if( $courseid[0] > 1 ) {
echo "Course ID Already in Exists<br/>";
} else {
$insertSQL = sprintf( "INSERT INTO tbl_course ( courseid, coursename, classstatus, startdate, starttime, enddate, endtime, ccc, venue, tutorid, remarks) VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
GetSQLValueString( $_POST['courseid'], "text" ),
GetSQLValueString( $_POST['coursename'], "text" ),
GetSQLValueString( $_POST['classstatus'], "text" ),
GetSQLValueString( $_POST['startdate'], "text" ),
GetSQLValueString( $_POST['starttime'], "text" ),
GetSQLValueString( $_POST['enddate'], "text" ),
GetSQLValueString( $_POST['endtime'], "text" ),
GetSQLValueString( $_POST['ccc'], "text" ),
GetSQLValueString( $_POST['venue'], "text" ),
GetSQLValueString( $_POST['tutorid'], "text" ),
GetSQLValueString( $_POST['remarks'], "text" ) );
mysql_select_db( $database_conn, $conn );
$Result1 = mysql_query( $insertSQL, $conn ) or die( mysql_error() );
$insertGoTo = "tc_success.php?action=Insert&tcid=" .$_POST['courseid'];
}
但是,它不适用于此代码。