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]." ");
}
echo("<br/>");
}
}
Thanks!
mysqli_fetch_rowfetched 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,