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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:07:07+00:00 2026-05-27T12:07:07+00:00

I have 2 php pages: query.php and result.php . In query.php , I am

  • 0

I have 2 php pages: query.php and result.php.

In query.php, I am executing a query (select) statement. It’s returning a resultset

$rs = mysql_query($query);

Now I want to return this resultset from query.php to another page result.php and work with it. Like this:

In query.php:

return $rs

and in result.php:

$result = executeQuery($query) // we get the resultset in this variable
while ($row == mysql_fetch_array($result){
//do something 
}

If the above is not recommended, please provide me with alternatives. But I want the query function and resultset in different pages.

  • 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-27T12:07:07+00:00Added an answer on May 27, 2026 at 12:07 pm

    You could just include results.php in your query.php page if you’re just looking to keep the code separate in the source files but aren’t actually required to redirect from one page to another:

    In query.php:

    $rs = mysql_query($query);
    include "results.php";
    

    In results.php:

    while ($row == mysql_fetch_array($rs){
      //do something 
    }
    

    As far as trying to “return $rs” from one page to another that’s not how PHP works. The return statement is only valid within a function. If you want to actually pass data from one PHP page to another and will be redirecting to that other page then you’ll need to use either a session, a cookie, pass it in the URL (i.e. use GET) or use curl and add it as a POST var.

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

Sidebar

Related Questions

I have a php page displaying query results from mysql. This result is displayed
I have a PHP page and I want to share some data between pages
I have a website which uses PHP and HTML pages, I want to create
so I have this query: SELECT COUNT( * ) AS cnt FROM table WHERE
I have the following pages: page1.php <?php if (isset($_GET['link'])) { session_start(); $_session['myvariable'] = 'Hello
I'm programming in PHP and would like to create web pages which have email
I have a <?php print $search_box; ?> in my page.tpl.php page. On pages that
I'm trying to do a simple search query in php with: SELECT * FROM
I have a search result from MySQL query or Array or something else. The
Sorry for the stupid question, but this is driving me crazy... I have test_framework.php

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.