How to break table row with mysql data

Asked

Viewed 128 times

-5

Hello I made a request system more would like to know how I can do to break the line after the commas . So when I print the order in the kitchen it comes as follows

Tambaqui rib : 1

Tabaqui Frito : 1

Fanta Orange : 1

Fanta Aran ja 2l : 1

and printing come more organized the application and next to quantities .

How could I do, I am grateful from now on .

inserir a descrição da imagem aqui

Code

<table>
  <thead>
    <tr>
                    <th >Comanda</th>
                    <th >N°Mesa</th>
                    <th >Refeição</th>
                    <th >Quantidade</th>
                    <th >Bebida</th>
                    <th >Quantidade</th>
                    <th  >Data</th>
                    <th >Acão</th>
    </tr>
  </thead>
  <tbody>
    <tr>
       <?php
            while($row = mysqli_fetch_array($consulta)){

                echo '<tr>';
                echo '<td ">'.$row["id_pedido"].'</td>';
                echo '<td ">'.$row["numero_mesa"].'</td>';
                echo '<td  >'.$row["pedido_refeicao"].'</td>';
                echo '<td >'.$row["num_refeicao"].'</td>';
                echo '<td >'.$row["pedido_bebida"].'</td>';
                echo '<td >'.$row["num_bebida"].'</td>';
                echo '<td >'.date("d/m/y H:i:s", strtotime($row["data"])).'</td>';

                echo '</tr>';

            }
                ?>
                <td><a href="form_alteracao.php?codigo=<?php echo $dado["usu_codigo"];?>">editar</a>
    </tr>
    <thead>
<table>
  • 1

    post the code that mounts the table

  • @Marcelobonifazio I HAVE DONE

  • vc not yet settled? see if this solves your problems http://kithomepage.com/sos/ped.php

1 answer

2

You have to manipulate the string before printing it using some functions within a cycle

<?php
$str = "abc, xyz, 123";

for( $i = 0; $i < strlen($str); $i++){
  $char = substr($str, $i, 1);
  if ($char == ","){
    $str = substr_replace($str, "<br>", $i+1, 0);
  }
}

echo "$str";
?>

For this code the output is:

abc,
xyz,
123

Browser other questions tagged

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