I figured out how to do it, without the need for ajax, javascript, table and others. I’ll explain with the example. I made the whole square matrix dynamic interface in the file "index.php".
First, I put the field that should update the interface. Using <form action="index.php" method="post">
, the entrance through the field <input name="numeroDeEquações" type="text" />
will reopen the "index.php" page with the variable $_POST['numeroDeEquações']
updated with the value that was passed in the field.
The second and last step is to determine the interface according to the field value. For this, I first check whether $_POST['numeroDeEquações']
defined. I then check if the value is valid. According to the conditions, the interface is built.
Simple as that. Follow the code and thank everyone who tried to help.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Matriz Quadrada</title>
</head>
<body>
<form action="index.php" method="post">
Ordem:    <input name="numeroDeEquações" type="text" /><br />
</form>
<?php
$inválido = true ;
if( isset($_POST['numeroDeEquações']) ){
$numeroDeEquações = $_POST['numeroDeEquações'] ;
if( $numeroDeEquações>1 && $numeroDeEquações<10 ){
$inválido = false ;
for( $índice1=0 ; $índice1<$numeroDeEquações ; $índice1++ ){
for( $índice2=0 ; $índice2<$numeroDeEquações ; $índice2++ ){
echo( "<input size=1 type='text' />" ) ;
}
echo( "<br>" ) ;
}
}
}
if( $inválido ) echo( "<br>Forneça um número de 2 a 9." ) ;
?>
</body>
</html>
This type of modification is done by Javascript, not PHP. What you know about Javascript?
– Woss
to pass the pro PHP variables is usually used
$_POST['exemplo']
or$_GET['exemplo']
, that takes the value of<input name="exemplo">
, as for the matrix, although it is MUCH easier with JS, it is also possible via PHP, throughforech
and a<table>
– Costamilam
Thanks. I found out here how to do more or less.
– RHER WOLF
only php dynamically without page att is not possible... just using ajax or javascript, as it does not update the page
– Matheus Lopes Marques