I want to create an array based on the results of my SELECT query.
The below code works somewhat -- it only adds the last row to the array. I tried declaring the array beforehand and then using array_push but that function doesn't allow me to assign a key, just a value.
$sql = "SELECT setKey,setValue FROM tblsettings WHERE setApp = '".$data->app."' AND setIP = '".gethostbyname(trim(gethostname()))."'";
$result = mysql_query($sql);
if(!$result) die(mysql_error());
if(mysql_num_rows($result) == 0){
echo "null";
exit;
}
while($datAssArr = mysql_fetch_assoc($result)){
$datArr = array($datAssArr["setKey"] => $datAssArr["setValue"]);
}
print_r($datArr);