Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8578827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:28:55+00:00 2026-06-11T20:28:55+00:00

I have this code which permits me to save (i guess so) the mysql

  • 0

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);
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:28:56+00:00Added an answer on June 11, 2026 at 8:28 pm

    Type casting does not convert a string to a array, you actually have to pass (and build) arrays:

    $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($firstdate, $seconddate);
    print_r($result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which permits me to get some ids $sql_id_att=SELECT DISTINCT att_id
i have this quick issue please. I have this code here which permits me
I have this code which searches a string array and returns the result if
I have this piece of code which permits me to print multiple dates, so
i have this code which permits me to do a request in order to
I have this code which permits me to insert some dates i've selected in
i have this piece of code which permits me to insert a title on
I have this code here please, which permits me to import data from a
I have this code which permits me to pass a variable to another page,
i have this code which permits me to retrieve all the information in which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.