zey zey February 2016

how to call the name instead of id?

Help don't know how to call the name of the position, My problem is my codition because when I change it to a position like 'Commissioner' it won't work but when I change to its id it will work but I want that my codition will be the name of the position, Please need help how to change this to a name: $dsds mean the id of the position

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 />';
        }
    }
}

Answers


Mouad Nejjari February 2016

instead of : if ($dsds == '9012'){ add : if ($row[1]== 'Commissioner')

Post Status

Asked in February 2016
Viewed 2,297 times
Voted 6
Answered 1 times

Search




Leave an answer