Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
99 views
in Technique[技术] by (71.8m points)

php - Pass the ticks into the database table

I am creating a connection with b/dbconnect3 ,there I have my connection.If my connection is error then to show me an error.Now ,I want to insert on my database table backg ,the ticks I am doing.

<?php 
require_once "b/dbconnect3.php";

if (mysqli_connect_errno()){
    printf("Connect failed : %s
", mysqli_connect_error($mysqli));
    exit();
}
else{
    $sql ="INSERT INTO backg (position) VALUES ('value 1') WHERE piece_color ='R' "; //I add and that now  because I want to add only in R
    $res = mysqli_query($mysqli, $sql);
    if ($res === TRUE) {
        echo "ok.";
    }
    else {
        printf("failed : %s
", mysqli_error($mysqli));
    }
    mysqli_close($mysqli);
}
?>

<form action="index.php" method="post">
  13<input type="checkbox" name="check_list[]" value="value 1"> a
    <br>
  14  <input type="checkbox" name="check_list[]" value="value 2">a
    <br>
 15   <input type="checkbox" name="check_list[]" value="value 3">a
    <br>
  16  <input type="checkbox" name="check_list[]" value="value 4">a
    <br>
17    <input type="checkbox" name="check_list[]" value="value 5">a
    <br>
18  <input type="checkbox" name="check_list[]" value="value 6">a
    <br>
19  <input type="checkbox" name="check_list[]" value="value 7">a
    <br>
20  <input type="checkbox" name="check_list[]" value="value 8">a
    <br>
21  <input type="checkbox" name="check_list[]" value="value 9">a
    <br>
22  <input type="checkbox" name="check_list[]" value="value 10">a
    <br>
23  <input type="checkbox" name="check_list[]" value="value 11">a
    <br>
24  <input type="checkbox" name="check_list[]" value="value 12">a
    <br>

     13<input type="checkbox" name="check_list[]" value="value 1"> b
    <br>
  14  <input type="checkbox" name="check_list[]" value="value 2">b
    <br>
 15   <input type="checkbox" name="check_list[]" value="value 3">b
    <br>
  16  <input type="checkbox" name="check_list[]" value="value 4">b
    <br>
17    <input type="checkbox" name="check_list[]" value="value 5">b
    <br>
18  <input type="checkbox" name="check_list[]" value="value 6">b
    <br>
19  <input type="checkbox" name="check_list[]" value="value 7">b
    <br>
20  <input type="checkbox" name="check_list[]" value="value 8">b
    <br>
21  <input type="checkbox" name="check_list[]" value="value 9">b
    <br>
22  <input type="checkbox" name="check_list[]" value="value 10">b
    <br>
23  <input type="checkbox" name="check_list[]" value="value 11">b
    <br>
24  <input type="checkbox" name="check_list[]" value="value 12">b
    <br>

    <button    type="submit" onclick="transfertoanotherpage()"  class='btn btn-primary'> End of turn</button>
    
</form>

here I am creating the database table

 CREATE TABLE  backg 
    ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
     `position` int(24) DEFAULT NULL,
     `pioni` enum('a','b') NOT NULL,
     `piece_color` enum('B','R') NOT NULL,
      `last_action` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
    )

and here is the problem that I managed to pass something and it is 0 ,lol check the image -I want to do it when I tick

enter image description here

I did blue as you can see the image to see that this it pass on my.I want to pass what I am doing tick

Edited I have a and b. On a I have positions 13 until 24 .The same with b,I have the positions 13 until 24.I want to tick 1 for a for positions 13 until 24 and 1 tick for positions 13 until 24 for b. As a result,I would like to,to store in database table(or tables) the values position and the letter a and also position and b for the tick I did.

question from:https://stackoverflow.com/questions/65560304/pass-the-ticks-into-the-database-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Alter table with this query:

ALTER TABLE `backg` CHANGE COLUMN `position` `position` int(24) unsigned DEFAULT NULL;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...