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 7428719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:50:56+00:00 2026-05-29T08:50:56+00:00

I have 2 separate arrays being pulled from MYSQL database, and want to combine

  • 0

I have 2 separate arrays being pulled from MYSQL database, and want to combine both arrays on the key, so I can use a php foreach statement.

*I tried doing 1 query with both, but could not figure out how to get my foreach $video[0] to work.*

match_descr = video code

m_date = date

SQL

    $query = "SELECT match_descr FROM  #__bl_match  WHERE match_descr != '' ORDER BY m_date DESC";
    $db->setQuery($query);
    $videomatch = $db->loadResultArray();

     $query = "SELECT m_date FROM  #__bl_match  WHERE match_descr != '' ORDER BY m_date DESC";
    $db->setQuery($query);
    $videomatch2 = $db->loadResultArray();

PHP

$video = $this->videomatch;

for ($i=1;$i<=1;$i++){
echo '<div id="videoFrame" align="left"><iframe name="videoFrame" title="YouTube video     
player" width="560" height="315"    src="http://www.youtube.com/embed/' . $video[0] . '" frameborder="0"     allowfullscreen=""></iframe></div>';
  echo '<br />';

 echo '<br />';
 echo '<div id="videoThumbnails" align="left">'; 
 echo '<table>';
foreach ($video as $value)
 {

  echo '<tr>';
  echo '<td>';
 echo '<a href="http://www.youtube.com/embed/' . $value . '" target="videoFrame"><img height="75px" width="123px" src="http://img.youtube.com/vi/' . $value. '/2.jpg" alt="' .     $value . '" />    </a>';
echo '</td>';
echo '<td>';
echo (THIS IS WHERE I WOULD LIKE TO PUT THIS VIDEOS DATE);
echo '<br />';
echo 'California';
echo '<br />';
echo '1-19-2012';
echo '</td>';
echo '</tr>';

}
echo '</div>';}
  • 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-05-29T08:50:57+00:00Added an answer on May 29, 2026 at 8:50 am

    You are (usually) better off selecting both rows in the same query:

    SELECT match_descr, m_date FROM  #__bl_match  WHERE match_descr != '' ORDER BY m_date DESC
    

    It appears that you are using Joomla. If this is the case, I don’t think you can use loadResultArray() to iterate multiple columns (you can give it an index to get one of the columns, but that’s not helpful in this case). Instead, you can use loadRowList to get an index array of the columns, or loadAssocList to get an associative array of the columns.

    They can be used as follows (without all the html for brevity):

    loadRowList:

    $query = "SELECT match_descr, m_date FROM  #__bl_match  WHERE match_descr != '' ORDER BY m_date DESC";
    $db->setQuery($query);
    $videomatch = $db->loadRowList();
    
    foreach ($videomatch as $row) {
        echo "{$row[0]} ({$row[1]})\n";
    }
    

    loadAssocList:

    $query = "SELECT match_descr, m_date FROM  #__bl_match  WHERE match_descr != '' ORDER BY m_date DESC";
    $db->setQuery($query);
    $videomatch = $db->loadAssocList();
    
    foreach ($videomatch as $row) {
        echo "{$row['match_desc']} ({$row['m_date']})\n";
    }
    

    Reference: http://docs.joomla.org/How_to_use_the_database_classes_in_your_script

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 separate java services that use a complex type that is a
I have three separate applications A, B and C. All of them use service
The problem: I have a custom collection PagedList<T> that is being returned from my
I have successfully implemented JQuery Sortable. I can also write it to the database
In my app I have a tableview being filled by values from an NSMutableArray.
What's the best way to have separate CSS for IE and other browsers? I'm
In my ASP.NET application I have separate projects for the Data, Business and UI
I have web application which we deployed in a production . We have separate
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
Say I have two separate classes, A and B. I also have Repository class

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.