I have a table that contains id and weight. I want to put both in an associative array.
Right now I've managed to put only the weight in an array:
$weight= array();
$stmt = $dbc->query("SELECT * FROM tbl_weight");
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$weight[] = $row['weight'];
}
I want to also put the id and make it an associative array.
For example for id = 1 and weight = 50, I want to be able to do something like:
$weight = array("1"=>"50");
How can I do this?