This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我正在创建一个搜索过程,我想检索MySQL数据库中的数据并将其显示在一个下拉列表中,每个表包含2个字段,一个是id,另一个是name

国家/地区的代码或功能运行得很好,但是专业化的其他功能却什么也没显示。如果有人可以帮助

function.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>';

  }


}
?>


index.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>

最佳答案

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

function specializtionQuery(){


...然后您致电:

<?php specializationQuery(); ?>


注意函数名称中缺少的a

关于php - php,从mysql数据库中检索数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15122144/

10-11 10:44
查看更多