需要帮助从Select into Database中保存答案

时间:2022-08-25 02:08:56

Hi there;

I need some help; I need to save the answer from a select into my database. I do not know where I went wrong. Here is some details regarding my code.

我需要一些帮助;我需要将select中的答案保存到我的数据库中。我不知道哪里出错了。以下是有关我的代码的一些细节。

  1. I have a database named 'lib'
  2. 我有一个名为'lib'的数据库

  3. The table is named 'games'
  4. 该表被命名为“游戏”

  5. I need to save the following into the table; 1) Game (all the words) and 2) Type
  6. 我需要将以下内容保存到表中; 1)游戏(所有单词)和2)类型

  7. It is for a tournament website. So that I can make it available on the LAN via XAMPP.
  8. 这是一个锦标赛网站。这样我就可以通过XAMPP在局域网上使用它了。

Here is my code. http://pastebin.com/iP7MCMzJ

这是我的代码。 http://pastebin.com/iP7MCMzJ

Thanks in advance!

提前致谢!

UPDATE:

Thanks for all the help! I have found and fixed my problem! In my database the VARCHAR was limited to 50 characters. I have fixed that. Now all is good :)

感谢您的帮助!我找到并解决了我的问题!在我的数据库中,VARCHAR限制为50个字符。我已经修好了。现在一切都很好:)

Thanks once again!

再次感谢!

1 个解决方案

#1


0  

Well, you're not showing any code but this is how I'd expect it to work based on your description:

好吧,你没有显示任何代码,但这是我希望它根据你的描述工作的方式:

Your HTML will want to look something like:

您的HTML将看起来像:

<?php echo '<option name="game" value="' . htmlentities($game) . '">' . $row['game'] . '</option>'; ?>

Notice the name attribute? Also, I changed the way the HTML was written as yours was very tough to read.

注意name属性?此外,我改变了HTML的编写方式,因为你的HTML非常难以阅读。

PHP

if(isset($_POST['game']) && isset($_POST['type'])){
$game = $_POST['game'];
$type = $_POST['type'];

// PLEASE CLEAN YOUR INPUT PRIOR TO INSERTING THIS DATA!

Insert into games (Game, Type) VALUES ($game, $type)
}
else{
echo( "error getting info");
}

#1


0  

Well, you're not showing any code but this is how I'd expect it to work based on your description:

好吧,你没有显示任何代码,但这是我希望它根据你的描述工作的方式:

Your HTML will want to look something like:

您的HTML将看起来像:

<?php echo '<option name="game" value="' . htmlentities($game) . '">' . $row['game'] . '</option>'; ?>

Notice the name attribute? Also, I changed the way the HTML was written as yours was very tough to read.

注意name属性?此外,我改变了HTML的编写方式,因为你的HTML非常难以阅读。

PHP

if(isset($_POST['game']) && isset($_POST['type'])){
$game = $_POST['game'];
$type = $_POST['type'];

// PLEASE CLEAN YOUR INPUT PRIOR TO INSERTING THIS DATA!

Insert into games (Game, Type) VALUES ($game, $type)
}
else{
echo( "error getting info");
}