1
<?php
session_start();
if(isset($_GET['nome'])){
$_SESSION['lista'][] = $_GET['nome'];
$_SESSION['lista'][] = $_GET['telefone'];
$_SESSION['lista'][] = $_GET['email'];
}
$lista = array();
if(isset($_SESSION['lista'])){
$lista = $_SESSION['lista'];
}
?>
...
<table style="width:100%" border="3">
<thead>
<tr>
<th>Nome</th>
<th>Telefone</th>
<th>E-Mail</th>
</tr>
</thead>
<tbody>
<?php foreach($lista as $lis): ?>
<tr>
<td><?=$lis?></td>
<td><?=$lis?></td>
<td><?=$lis?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
...
When displaying in the table a line is occupied by names, and the next line by phones, how can I resolve this so that a line has name, phone and email?
Knows the
foreach
of PHP?– Woss
Use the [Edit] button to add more information to the question.
– Woss
Yes, I am using the foreach, the problem is in that piece of code, when passing to the array to $_SESSION, which I am not able to do, who can help with code thank.
– NitrousHang
What a piece of code?
– Woss
Yes, but my question is how to store three variables, name, phone and email, in a $_SESSION, and then save and array and display with foreach in the table. Anyone can help ?
– NitrousHang
You’re already doing this. What’s the problem? What is the code that uses
foreach
? Edit the question and ask it.– Woss
I edited, placing the foreach part
– NitrousHang
Will be multiple names, phones and email stored in session?
– Woss
Exactly, to each register in the form, new lines with name, telephone and email.
– NitrousHang