Hi,
im using this function as the method of retrieving DB results via SELECT statements and putting them into an array.
function select($sqlquery) {
$query = mysql_query($sqlquery);
$result = array();
$table = array();
$field = array();
$tempResults = array();
$numOfFields = mysql_num_fields($query);
for ($i = 0; $i < $numOfFields; ++$i) {
array_push($table,mysql_field_table($query, $i));
array_push($field,mysql_field_name($query, $i));
}
while ($row = mysql_fetch_row($query)) {
for ($i = 0;$i < $numOfFields; ++$i) {
//$table[$i] = trim(ucfirst($table[$i]),"s");
$table[$i] = ucfirst($table[$i]);
$tempResults[$table[$i]][$field[$i]] = $row[$i];
}
array_push($result,$tempResults);
}
return $result;
}
the problem ive got is when doing a UNION select statement the array is returned in the following format:
Array ( [0] => Array ( => Array ( [username] => test [password] => qwerty [userid] => 19 ) ) )
the problem lies with the additional array key which is blank.
how can i remove this so this so it resemble normal select statement arrays like this:
Array( [0] => Array ( [username] => james [password] => qwerty [userid] => 19 [chatcomment] => gggggggggfghgfh [usertype] => Tblstudents ) ) )
or even better, does anyone have any suggestions about how i can do this better and make sure the array is always the correct way.
thanks,
phphelpee