<!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>无标题文档</title>
</head>

<body>
<select>

<?php

    //造链接对象
    $db=new MySQLi("localhost","root","123456","xinjian");
    
    //判断是否出错
     !mysqli_connect_error() or die("链接失败");
     
     //写sql语句
     $sql="select * from nation";
     
     //执行sql语句
     $result=$db->query($sql);
    
    //处理数据
    $attr = $result->fetch_all();
    
    //遍历并显示
    for ($i=0;$i<count($attr);$i++)
    {
        list($code,$name)=$attr[$i];
        echo "<option value='{$code}'>{$name}</option>";
        
        }



?>

</select>




</body>
</html>

下拉表单

相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2021-07-24
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2022-01-10
  • 2021-07-04
  • 2022-12-23
  • 2021-12-04
  • 2021-12-01
  • 2021-11-05
相关资源
相似解决方案