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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:05:47+00:00 2026-06-03T15:05:47+00:00

This is probably not a very difficult question to answer. I’m having trouble with

  • 0

This is probably not a very difficult question to answer. I’m having trouble with this PHP function I wrote… it returns the rows line by line, but it’s returning them incremented by 4 each time. So the the 1st row will output, then the 5th, then the 9th…

function showDatabases() {

# $_GET variables from the URL.
$database = mysql_real_escape_string($_GET['database']);
$table    = mysql_real_escape_string($_GET['table']);   

$mysqli = new mysqli('127.0.0.1', 'root', '', $database);

$query_one = $mysqli->query("SELECT * from $table");

$num_rows   = mysqli_num_rows($query_one);
$num_fields = mysqli_num_fields($query_one);

    for ($x = 0; $x < $num_rows; $x++) {
       for ($c = 0; $c < $num_fields; $c++) {
            $row = mysqli_fetch_row($query_one);
            echo($row[$c]."&nbsp;&nbsp;");
       }
    echo("<br/>");
    }
}

Thanks!

  • 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-03T15:05:49+00:00Added an answer on June 3, 2026 at 3:05 pm

    mysqli_fetch_row fetched an entire row and moves the pointer to the following row. You should call it only once per each row; now you are calling it once per column.

    That is,

    for ($x = 0; $x < $num_rows; $x++) {
       $row = mysqli_fetch_row($query_one);
       for ($c = 0; $c < $num_fields; $c++) {
            echo($row[$c]."&nbsp;&nbsp;");
       }
    echo("<br/>");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm very aware that this is probably not a stackoverflow question, but i figure
This probably has a simple answer, but I must not have had enough coffee
This is probably a simple question but I am not an ASP.NET developer and
This is probably not very elegant, but what I'm trying to do is connect
this is probably not explained very well but please bear with me, I've also
This is probably not possible, but I have this class: public class Metadata<DataType> where
Okay, I know that 1) this is probably not possible with CSS alone and
this c# code is probably not the most efficient but gets what I want
This is weird and probably not possible but I'll ask anyway. I'm making this
I know this probably really simple but Im not sure what im doing wrong...

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.