dougao2830 2016-05-30 12:41
浏览 59

查询php / mysql中的全局变量

I have a website with 3 dropdown menus that loop through a database in mysql to get 50 bands in a list you can chose. I have made it so if you vote for band number 1, he gets 10 points, number 2, 6 points etc.. Now i have the problem that you can vote for 3 the same bands bcs those dropdown are each looping trough the database. I want to make a global variable so i can put in the query from dropdown 1 of 2 that it doesnt show the chose in dropdown 1.. so like "WHERE NOT LIKE 'variable'" Here is my code for dropdown 1:

<?php echo '<select name="bands1">';
      echo '<option>Kies een band</option>';

$sql="SELECT * FROM bands ORDER BY band"; 
$result = mysqli_query($db_link, $sql);


if (!$result){
      die ("Database connection failed!");
}

while($row = mysqli_fetch_assoc($result)){

echo '<option value="' . $row['BandID'] . '">' . $row['band'] . '</option>'; 

}

echo '</select>';
?>

this is for the 2 other dropdown menus the same only the select name is different

this is my connection file that i included at the top of the html file:

<?php
define('DB_HOST',  'localhost');
define('DB_USER',  'root');
define('DB_PASS',  '');
define('DB_NAME',  'mysql_enquete');

$db_link = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die ("Verbindingsfout");
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);


if (mysqli_connect_errno()) {
    printf("Connect failed: %s
", mysqli_connect_error());
    exit();
}

if ($result = $mysqli->query("SELECT DATABASE()")) {
    $row = $result->fetch_row();
    printf("", $row[0]);
    $result->close();
}
?>

Somebody on stackoverflow that can help me?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?