Hi guys, so basically im selectin a row called ‘job’ which could have different numbers from 0 to 6. And im just trying to put this into an array something like this.
$plec = array(
'0' => 'sm1',
'1' => 'sm2',
'2' => 'sm3',
'3' => 'sm3',
'4' => 'sm4',
'5' => 'sm5',
'6' => 'sm6',
);
$sql1 = $player->prepare('SELECT id, name, job, level FROM player WHERE account_id = ?');
$sql1->bind_param('i', $_SESSION['id']);
$sql1->execute();
$result = $sql1->get_result();
$charCount = $result->num_rows;
if($charCount == 0) {
echo 'n/a';
}else {
echo $plec[0];
while($row = $result->fetch_assoc()) {
echo '<td>Something</td>';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['name'].'</td>';
}
}
So now the output is going to be
echo $plec[0];
output:
sm1
So how i get the query to automatically collab with the array? So the array can output whatever will the query spill out.