我目前正在编程井字游戏,我试图让玩家选择在游戏结束时重玩游戏。
我为此使用结构,但是我不断收到类似于“ error的错误消息:成员引用基本类型'int'不是结构或联合 grid [gridsize] [gridsize] = make_move(ReplayX.X [sequence_number],ReplayX.Y [sequence_number],ReplayX.player); “
网格声明
formprocessor.php
结构代码...
<?php
// starting a session so we can go back to main page
session_start();
// Connect to mysql database
$mysqli = new mysqli('127.0.0.1','root',"",'v2HospitalDB') or die(mysqli_error($mysqli));
// Reset values to empty
$firstname = "";
$lastname = "";
$departID = "";
$special = "";
$update = false;
$id = 0;
// Check if the save button has been pressed
if(isset($_POST['save'])){
// store columns from database
$firstname = $_POST['fname'];
$lastname = $_POST['lname'];
$departID = $_POST['departmentID'];
$special = $_POST['speciality'];
// Insert records into database
$mysqli -> query("INSERT INTO Doctor(doctorFName , doctorLname , idDepartment, specialty)
VALUES('$firstname', '$lastname', '$departID' , '$special')") or
die($mysqli->error);
// will show at top of screen once the record has been saved
$_SESSION['message'] = "You have saved a record into the database";
$_SESSION['msg_type'] = "success";
// redirect back to the index.php after inserting records
header("location: index.php");
}
// This will delete the record from the table based on the id
if(isset($_GET['delete'])){
$id = $_GET['delete'];
$mysqli->query("DELETE FROM Doctor WHERE idDepartment AND doctorID = '$id'") or die($mysqli->error);
// When you delete a record, will show at top of screen
$_SESSION['message'] = "You have saved a deleted a record from the database";
$_SESSION['msg_type'] = "danger";
session_destroy();
// redirect back to the index page
header("location:index.php");
}
// If the edit button is clicked
if(isset($_GET['edit'])){
$update = true;
$id = $_GET['edit'];
// change back to where doctorId and idDepartment
$result = $mysqli->query("SELECT * FROM Doctor WHERE doctorID = '$id'") or die($mysqli->error);
// will fetch all colums in table from the result array
// If the record has been found in the database
if(count($result) == 1){
$row = $result->fetch_array();
$firstname = $row['doctorFName'];
$lastname = $row['doctorLname'];
$idDepart = $row['idDepartment'];
$special = $row['specialty'];
// echo (var_dump($result));
}
// will show at top of page when user updates the table
$_SESSION['message'] = "Record has been selected";
$_SESSION['msg_type'] = "info";
session_destroy();
header('location: index.php');
}
// If user clicks update then will insert values into columns
if(isset($_POST['update'])){
$id = $_POST['id'];
$firstname = $_POST['doctorFName'];
$lastname = $_POST['doctorLname'];
$idDepart = $_POST['idDepartment'];
$special = $_POST['specialty'];
$mysqli->query("INSERT INTO Doctor(doctorFName, doctorLname, idDepartment, specialty) VALUES
('$firstname', '$lastname', '$idDepart', '$special' ");
// will show at top of page when user updates the table
$_SESSION['message'] = "Record has been updated";
$_SESSION['msg_type'] = "warning";
session_destroy();
header('location: index.php');
}
重播代码...
#define MaxGrid 10
char grid[MaxGrid][MaxGrid];
游戏可以在3到10的网格上进行游戏,因此grid [gridsize] [gridsize]是存储X或O的二维数组。
MakeMove是一项功能,可将网格中的字符从'更改为'。字母X或O。