Warning: mysqli_fetch_array () expects at most 2 parameters, 3 given

1

Does anyone know how I can do so that the mysqli_fetch_array can read me 3 parameters ?

$registros = 1; //registros por página
$sql = "SELECT * FROM base1";
$result = mysqli_query($conec, $sql);
$reg_total = @mysqli_num_rows($result);

//total de páginas
$pag = ceil($reg_total / $registros);

@mysqli_free_result($result);

if (!isset($_GET['screen']))
$screen = 0;
$position = 0;

$inici = $screen * $registros;
//consulta
$sql = "SELECT * FROM base1 order by ID ASC LIMIT ".$position.",".$registros;
//query
$result = mysqli_query($conec, $sql);
$rows = @mysqli_num_rows($result);

//mostrar registros
for ($i = 0; $i < $rows; $i++) {
$titol = mysqli_fetch_row($result,$i,1);
$video = mysqli_fetch_array($result,$i,2);
echo ("<h1> $titol </h1>");

echo ("<video width='600px' height='400px' controls>
  <source src='$video' type='video/mp4'>
</viedo>");
}


//anterior, numero, siguiente
echo '<p><hr></p>
<div style="widht:100%; text-align:center;">';

//registro anterior
if ($position >= 1) {
$url = "cap.php?screen=" .($position-1);
echo "<a href=\"$url\">Anterior</a>\n";
}

//mostrar registro actual
echo '<strong>'.($position+1).' de '.$pag.' <strong>';

//siguiente registro
if ($position < ($pag-1)) {
$url = "cap.php?screen=" . ($position+1);
echo "<a href=\"$url\">Siguiente</a>\n";
} 
echo '</div>';

?>

What I want to do is a pagination of only 1 record per page

$registros = 1; //registros por página
$sql = "SELECT * FROM base1";
$result = mysqli_query($conec, $sql);
$reg_total = @mysqli_num_rows($result);

//total de páginas
$pag = ceil($reg_total / $registros);

@mysqli_free_result($result);

if (!isset($_GET['screen']))
$screen = 0;
$position = 0;

$inici = $screen * $registros;
//consulta
$sql = "SELECT * FROM base1 order by ID ASC LIMIT ".$position.",".$registros;
//query
$result = mysqli_query($conec, $sql);
$rows = @mysqli_num_rows($result);

//mostrar registros
for ($i = 0; $i < $rows; $i++) {
$titol = mysqli_fetch_row($result,$i,1);
$video = mysqli_fetch_array($result,$i,2);
echo ("<h1> $titol </h1>");

echo ("<video width='600px' height='400px' controls>
      <source src='$video' type='video/mp4'>
    </viedo>");
}


//anterior, numero, siguiente
echo '<p><hr></p>
<div style="widht:100%; text-align:center;">';

//registro anterior
if ($position >= 1) {
$url = "cap.php?screen=" .($position-1);
echo "<a href=\"$url\">Anterior</a>\n";
}

//mostrar registro actual
echo '<strong>'.($position+1).' de '.$pag.' <strong>';

//siguiente registro
if ($position < ($pag-1)) {
$url = "cap.php?screen=" . ($position+1);
echo "<a href=\"$url\">Siguiente</a>\n";
}
echo '</div>';

?>
    
asked by DarkSpace 05.08.2018 в 01:13
source

1 answer

1

It is not very clear what you are trying to do, but possibly what you want is to obtain the elements of your query.

First you have to keep in mind that mysqli_fetch_array

  

Returns an array of strings corresponding to the row obtained or NULL   if there are no more rows in the resultset.

and has a maximum of two parameters:

  

result

     

Process style only: A set of result identifiers returned by mysqli_query() , mysqli_store_result() or    mysqli_use_result() .

     

resulttype

     

This optional parameter is a constant that indicates what type of array should be generated with the information of the current row. The   Possible values for this parameter are the constants MYSQLI_ASSOC ,    MYSQLI_NUM , or MYSQLI_BOTH .

     

By using the constant MYSQLI_ASSOC this function will behave identically to mysqli_fetch_assoc() , while with MYSQLI_NUM it will   will behave exactly like the mysqli_fetch_row() function. The   last option MYSQLI_BOTH will create a single array with the attributes of   both two.

Therefore, what you are trying to do is not correct.

If what you want is to obtain the results of your query do this:

$rows = mysqli_fetch_array($result);    

$titol = rows[0]; // la primera fila de tu consulta
$video = rows[1]; // la segunda fila de tu consulta

echo ("<h1> $titol </h1>");
echo ("<video width='600px' height='400px' control
<source src='$video' type='video/mp4'>
</video>");
    
answered by 05.08.2018 в 01:25