0

我正在创建一个搜索过程,我想检索 MySQL 数据库中的数据并将其显示在下拉列表中,每个表包含 2 个字段,一个是 id,另一个是名称

该国家的代码或功能运行良好,但专业化的其他功能不显示任何内容。如果有人可以帮助请

函数.php

<?php
 require_once('db.inc.php'); 

function connect(){
   mysql_connect(DB_Host, DB_User ,DB_Pass )or die("could not connect to the database" .mysql_error());

   mysql_select_db(DB_Name)or die("could not select database");

}
  function close(){

  mysql_close();

  }

  function countryQuery(){

  $countryData = mysql_query("SELECT * FROM country");

  while($record = mysql_fetch_array($countryData)){

     echo'<option value="' . $record['country_name'] .  '">' . $record['country_name'] . '</option>';

  }

}

function specializtionQuery(){

$specData = mysql_query("SELECT * FROM specialization");

  while($recordJob = mysql_fetch_array($specData)){

     echo'<option value="' . $recordJob['specialization'] .  '">' . $recordJob['specialization'] . '</option>';

  }


}
?>

索引.php

<?php
  require_once('func.inc.php'); 
  connect(); 


?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testDroplistdown</title>
</head>

<body>
<p align="center">
<select name="dropdown">
  <?php countryQuery(); ?>
</select>
  <?php close(); ?>
</p>
<p align="left">
<select name="dropdown2">
  <?php specializationQuery(); ?>
</select>
  <?php close(); ?>
</p>


</body>
</html>
4

1 回答 1

1

您在定义中拼错了函数名称:

function specializtionQuery(){

...然后你打电话给:

<?php specializationQuery(); ?>

请注意函数名称中的缺失a

于 2013-02-27T20:52:59.777 回答