I have this code which permits me to save (i guess so) the mysql results into an array, i get then, two arrays and i need to merge them into one!
The problem is apparently it won’t merge in the correct way, it merges but not all values..
What am i doing wrong here?
Thanks!
<?php
$date1=mysql_query("SELECT date FROM date WHERE att_id='$att_id'");
$date2=mysql_query("SELECT date FROM date_pdv WHERE att_id='$att_id'");
while ($row = mysql_fetch_array($date1, MYSQL_ASSOC)) {
printf("Data: %s", $row["date"]);
$firstdate=$row['date'];
}
while ($row = mysql_fetch_array($date2, MYSQL_ASSOC)) {
printf(" Data1: %s", $row["date"]);
$seconddate=$row['date'];
}
$result = array_merge((array)$firstdate, (array)$seconddate);
print_r($result);
?>
Type casting does not convert a string to a array, you actually have to pass (and build) arrays: