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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:47:30+00:00 2026-05-24T04:47:30+00:00

I want two functions. First function stores info, while the second one displays the

  • 0

I want two functions. First function stores info, while the second one displays the info. How would I get the second function to display all that is stored in $info_id and $info_title?

 function get_info()
 {
   $dbc = get_dbc();
   $info = mysqli_query($dbc, "SELECT info_id, info_title FROM text") or die("Error: ".mysqli_error($dbc));
   while ($info_row = mysqli_fetch_array($info))
   {
     $info_id = $info_row['info_id'];
     $info_title = $info_row['info_title'];
   }
 }
  • 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-24T04:47:31+00:00Added an answer on May 24, 2026 at 4:47 am

    You can split that function into two using the following approach:

    function get_info()
    {
      $result = array();
    
      $dbc = get_dbc();
      $info = mysqli_query($dbc, "SELECT info_id, info_title FROM text") or die("Error: ".mysqli_error($dbc));
    
      while ($info_row = mysqli_fetch_array($info))
      {
        $result[] = $info_row;
      }
    
      mysqli_free_result($info); // it is good practice to free the result yourself
      return $result;
    }
    
    function display_info(array $result)
    {
      foreach ($result as $info_row) {
        echo 'id: ' . $info_row['info_id'] . "\n";
        echo 'title: ' . $info_row['info_title'] . "\n";
      }
    }
    

    You then can call the functions the following way:

    $info = get_info();
    // do stuff
    display_info($info);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a function that accepts two objects as parameters and compare
I want to build two-dimentional array of strings where length of one dimention is
I want to update two columns in a table. The value of the second
When moving a file from old.package to new.package I want two things to happen:
I want to swap two integers, and I want to know which of these
I want to compare two ms-access .mdb files to check that the data they
I want to have two items on the same line using float: left for
I want to declare two beans and instantiate them using Spring dependency injection? <bean
Hi I want to have two tables each have an INT id column which
I am working on an If statement and I want to satisfy two conditions

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.