从数据库召回到dropmenu无法正常工作

时间:2014-07-05 20:40:52

标签: php mysql

美好的一天,提前感谢您的时间和耐心

我正在开发一个php脚本,它有多个下拉菜单,其中包含来自数据库的搜索查询,我之前已经完成了这个,但今天我不确定为什么但它无法正常工作。它没有给我任何错误,所以与数据库的连接工作,我认为它不会填充,实际上它一起切断PHP代码.....

我的connect / connect-mysql.php

<?php

DEFINE ('DB_HOST', 'myipishere');
DEFINE ('DB_USER', 'entest');
DEFINE ('DB_PSWD', 'passishere');
DEFINE ('DB_NAME', 'tester');

$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME);

if (!$dbcon) {
    die('error connecting to database');
    }

?>

数据库包含

的设置
CREATE TABLE `classes` (
  `Class` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`Class`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

带有测试数据

INSERT INTO `classes` VALUES ('tank'), ('warrior'), ('fighter'), ('archer');

我的insert.php看起来像这样

<form method="post" action="insert.php">
<input type="hidden" name="submitted" value="true" />
<?php
echo $newrecord // New record added statement added at the top
?><table border="0" width="100%" cellpadding="0">
<tr><td>
<table border="1" width="100%" style="border-collapse: collapse">
<tr>
<td width="150">&nbsp;</td>
<td>Main Class 
<select size="1" name="Class">
<option value="" selected>select</option>
<?php
include('../connect/connect-mysql.php');

$sql3="SELECT class FROM classes Order by class asc";
$results = mysqli_query($dbcon,$sql3) or die('123');

while($row = mysqli_fetch_array($results)) {

      echo '<option value="'.$row['class'].'">'.htmlspecialchars($row['class']).'</option>'; 
  }                         
?>
</select>

Lvl <select size="1" name="lvl"><option value="3">3</option><option value="17">17</option><option value="55">55</option></select>
            </td>
</tr></table>
<input type="submit" value="submit">
</form>

然而,当我上传并尝试查看它是否有效时,它只能

<form method="post" action="insert.php">
<input type="hidden" name="submitted" value="true" />
<?php
echo $newrecord // New record added statement added at the top
?><table border="0" width="100%" cellpadding="0">
<tr><td>
<table border="1" width="100%" style="border-collapse: collapse">
<tr>
<td width="150">&nbsp;</td>
<td>Main Class 
<select size="1" name="Class">
<option value="" selected>select</option>

然后停止

请帮助....如果您需要更多信息,请问我更愿意提供更多信息。

0 个答案:

没有答案