Home > database >  Aligning data in a table according to each characteristics in php
Aligning data in a table according to each characteristics in php

Time:12-26

I get data from a mssql database that I want to display in a table. The table has three categories: ORDER NUMBER PAYMENT STATUS ORDER STATUS

The problem is as follows: I would like to align my order numbers with the payment status and the order status in order to have a nice table that is well aligned.

Here is my code in php and the result it gives me :

<!DOCTYPE html>
 <html>
 <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" type="text/css" href="css/clientsS.css">
     <title></title>
 </head>
 <body>
    <div >
    <div >
        <center><table>
            <tr>
                <th>NUMERO COMMANDE</th>
                <th>STATUT PAIEMENT</th>
                <th>STATUT COMMANDE</th>
            </tr>

            <tr>
                <td><?php
            //CONNEXION ODBC SERVER//
            $dsn="";
            $user="";
            $password="";
            $conn=odbc_connect($dsn
                ,$user, $password);

            //REQUETES
            $sql = <<<EOF
                    SELECT top 10 [enc_cmd_num]
                    FROM [encaissement]
                    WHERE enc_date= '20221220'
                    EOF;

            $results = odbc_exec($conn,$sql);
            

            while($resultrow = odbc_fetch_array($results)){ 
                echo $resultrow["enc_cmd_num"]."<br/>" ; }
                ?>

            </td>
        </div>

        <div >

            <td><?php
            //CONNEXION ODBC SERVER//
            $dsn="";
            $user="";
            $password="";
            $conn=odbc_connect($dsn,$user, $password);

            //REQUETES
            $sql = <<<EOF
                    SELECT top 10 [enc_paye]
                    FROM [encaissement]
                    WHERE enc_date= '20221220'
                    EOF;

            $results = odbc_exec($conn,$sql);

            //CONDITION
                while($resultrow = odbc_fetch_array($results)) {
                    switch($resultrow['enc_paye']){
                    case 0:
                        echo "<p>En attente paiement</p> \r\n";
                        break;
                    case 1:
                        echo "<p class='green'>Commande payée<p/>\r\n";
                        break;
                }

            }
?>
</td>
                <td><?php
            //CONNEXION ODBC SERVER//
            $dsn="";
            $user="";
            $password="";
            $conn=odbc_connect($dsn,$user, $password);

            //REQUETES
            $sql = <<<EOF
                    SELECT top 10 [enc_prepared]
                    FROM [encaissement]
                    WHERE enc_date= '20221220'
                    EOF;

            $results = odbc_exec($conn,$sql);

            //CONDITION

                while($resultrow = odbc_fetch_array($results)) {
                    switch($resultrow['enc_prepared']){
                    case 0:
                        echo "<p>Commande en attente</p> \r\n";
                        break;
                    case 1:
                        echo "<p class='yellow'>Commande en cours de préparation<p/>\r\n";
                        break;

                }

            }



?>

</td>
</tr>
</table>

</div>

SCREEN OF THE RESULT

CodePudding user response:

It is preferable that you use the same tag <p> even for the first <td>:

Test it like this and tell me if it works for you:

echo "<p>".$resultrow["enc_cmd_num"]."<p/>" ;

Instead of:

echo $resultrow["enc_cmd_num"]."<br/>" ;
  • Related