如何调用名称而不是id?

时间:2016-02-09 01:10:53

标签: php

帮助不知道如何拨打职位名称,我的问题是我的问题,因为当我将其改为像“专员”这样的职位时。它不会起作用但是当我改变它的id它会起作用但是我希望我的代码将是该位置的名称,请求帮助如何将其更改为名称:$dsds表示id职位

data struct example

<?php
include ('../connection/connect.php');

$result = $db->prepare("SELECT * FROM candposition ORDER BY posid ASC");
$result->bindParam(':userid', $res);
$result->execute();

for ($i = 0; $row = $result->fetch(); $i++) {

    $dsds = $row['posid'];

    for ($i = 0; $rows = $results->fetch(); $i++) {

        if ($dsds == '9012') {

            $result = $db->prepare("SELECT * FROM program ORDER BY progid ASC");

            echo $rows['progid'];
            echo '<br />';
            echo '<div  style = "margin-left:2px;display:inline-block;position:relative;">';
            echo '<img src="candidates/images/' . $rows['image'] . '" width="90" height="100px" />' . ',&nbsp;' . '<br />' . $rows['lastname'] . ',&nbsp;' . $rows['firstname'] . '<br />' . '&nbsp;=&nbsp;' . $rows['votes'];
            echo '<br />';
        }
    }
}

1 个答案:

答案 0 :(得分:1)

代替:if ($dsds == '9012'){添加:if ($row[1]== 'Commissioner')