Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Aligning data in a table according to each characteristics in php

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<!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 class="BLOC1">
    <div class="NUMBER">
        <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 class="TITRE">

            <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

>Solution :

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:

<!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 class="BLOC1">
    <div class="NUMBER">
        <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 "<p>".$resultrow["enc_cmd_num"]."<p/>" ; }
                ?>

            </td>
        </div>

        <div class="TITRE">

            <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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading