dqq3623 2013-11-14 13:21
浏览 68
已采纳

从mysql填充的PHP下拉菜单不起作用

I've spent hours reading and trying to figure out why this is not working but the drop down menu does not populate. I think it's something simple but I just cannot see it. Anyone?

dbconn.php

<?php

define('DB_NAME' , 'artprints');
define('DB_USER' , 'root');
define('DB_PASS' , '');
define('DB_HOST' , 'localhost');

func.php

<?php

include_once 'dbconn.php';

function connect(){
    $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS) or die ('Could not connect to the database' . mysl_error());
    mysqli_select_db($connection, DB_NAME);
}

function close(){
    mysql_close();
}

function query(){
    $myData = mysql_query("SELECT * FROM artists");
    while ($record = mysql_fetch_array($myData)){
    echo '<option value="' . $record['artistID'] . '">' . $record['artistID'] . '</option>';
    }
}

test.php

<?php
 include_once 'func.php';
 connect();
 ?>

 <html>
 <head>
 <title>Drop down testing</title>
 </head>
 <body>
 <select name='artist'>
 <?php query() ?>
 </select>
 <?php close() ?>
 </body>
 </html>
  • 写回答

2条回答 默认 最新

  • douzhenqun1271 2013-11-14 13:24
    关注

    You are mixing mysqli_* and mysql_*

    mysqli_connect and mysqli_select_db

    against

    mysql_query and mysql_fetch_array

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助