How to display a horizontal array?

Asked

Viewed 258 times

1

I am unable to print a horizontal array on an HTML page. How can I do this?

PHP:

if (isset($_GET['nome']) && $_GET!=['nome']) {
    $lista_tarefa = array();
    $lista_tarefa['nome'] = $_GET['nome'];
}



if (isset($_GET['descricao'])) {
    $lista_tarefa['descricao'] = $_GET['descricao'];
} else {
    $lista_tarefa['descricao'] = '';
}

PHP+HTML:

  <table>

  <?php foreach ($lista_tarefa as $tarefa) : ?>

       <tr>
           <td> <?php echo $tarefa; ?> </td>
        </tr>

   <?php endforeach; ?>

 </table>
  • Are you sure that first if this right? do not understand that $_GET!=['nome']

  • The right thing is: $_GET!= ['name']!=''

  • Still seems to be wrong.

  • No, that’s how it is. But, another problem has arisen... I have 5 input="text" and I want to add 5 values and when calling my Ubmit, print them in a table horizontally. OK, I got this. But, I want to add 5 more, 5 more and 5 more... But in doing so he prints beside it, I want him to go down and print on the bottom line. How do I do this?

  • Open another question. And if the answer is right. Mark as correct.

1 answer

3

Just leave the "td" inside the loop.

  • This does not provide an answer to the question. To criticize or ask for clarification from an author, leave a comment below its publication - you can always comment on your own publications and when you have reputation points enough you will be able comment on any publication.

  • @Erloncharles that’s an answer to the question, whether it’s right or wrong, that’s something else.

  • 1

    It is not a question of right or wrong, it would be interesting to show also how to do this based on the code of the question and explain the reasons for this, ie make a more complete answer. Just as she is she’s more of a q comment a reply

  • In my humble opinion is to complicate the simple, anyway, the community or the author himself will select the best answer. Now you want her to write a book to move an if.

  • That’s exactly it, thank you. but another problem has arisen... I have 5 input="text" and I want to add 5 values and when calling my Ubmit, print them in a table horizontally. OK, I got this. But, I want to add 5 more, 5 more and 5 more... But in doing so he prints beside it, I want him to go down and print on the bottom line. How do I do this?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.