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

  • Home
  • SEARCH
  • 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 8818749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:11:00+00:00 2026-06-14T05:11:00+00:00

So I have an excel file. I have multiple queries that are returned. However

  • 0

So I have an excel file. I have multiple queries that are returned. However I need to run all these queries at once and output the results to the excel file.

$col = 1;
while($row_data = mysql_fetch_assoc($result)) {
$row = 1;
if ($col == 1) {
    $row_headings = array_keys($row_data);
       foreach($row_headings as $value) {
    $h = preg_split('/X/', $value);

if ($h[0] = $id and $h[2] != null){
$results="select question from lime_questions where sid =".$h[0]." and gid =".$h[1]." and qid =".$h[2]."; ";
echo $results;
//This is where the queries are returned. 
//They are echoed to the first cell of the excel file
//They are returned as "query1;query2;..."
//This is where I am messing up. 
//I am attempting to run the queries. I have been attempting many different approaches

$query_result = mysql_query($results[0]); //this does not return results of the queries
echo $query_result;
//attempting to show the results in the first cell of the excel file
     }
//ideally at this point this foreach would print each query result in its own cell
 foreach(mysql_query($results) as $value2){
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value2);
        $row++;
     }
    $row = 1;
    $col++;
}
  • 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-14T05:11:01+00:00Added an answer on June 14, 2026 at 5:11 am

    You might try mysqli_multi_query in PHP 5.

    https://www.php.net/manual/en/mysqli.multi-query.php

    Other than that, nested queries "should" work. It’s possible you have the wrong key/value elements being targeted. Difficult for me to say without access to the schema being used.

    But I agree, the old functions are going to deprecate, so need to be updated with newer scripting methods.

    <?php
    $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
    
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    $query  = "SELECT CURRENT_USER();";
    $query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
    
    /* execute multi query */
    if ($mysqli->multi_query($query)) {
        do {
            /* store first result set */
            if ($result = $mysqli->store_result()) {
                while ($row = $result->fetch_row()) {
                    printf("%s\n", $row[0]);
                }
                $result->free();
            }
            /* print divider */
            if ($mysqli->more_results()) {
                printf("-----------------\n");
            }
        } while ($mysqli->next_result());
    }
    
    /* close connection */
    $mysqli->close();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel file that I need to make some changes. I need
I have an Excel file that I need to import into a (new) Oracle
I have an Excel file that gets external data from database table. I need
I have an excel file that I want to embed in my C# assembly.
I have a large excel file that is used to aggregate tracking for issues
I have a macro that allows a user to browse and select multiple Excel
I have an excel file with 815 records that includes service name and charge.
I currently have an excel file (.htm) that I use as a template for
I am having few excel files where each file have multiple workbooks. Assume following
We have an automatic process that opens a template excel file, writes rows of

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.