0

as seen in the pic a table. I have the following im trying to fill the boxes based on rows. So line one will fill by the correct ordergoing left to right then down. here is my code.

        $results = mysqli_query($con, " SELECT * FROM PMAsset Order by Linenum, LineOrder") or die(mysqli_error($con));
        while($row = mysqli_fetch_array($results)) {
        ?>
            <tr>
                <td bgcolor="aabbcc"><center><?php echo $row['LineNum']?></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>
                <td Bgcolor=<?php echo $row['PMStatus']?>></td>

            </tr>

        <?php
        }
        ?>

I know im missing a loop but not sure how or where to do it. I want the boxes to sort by Line number then lineorder. then if line is 2 drop to next boxes ect. I have to allow for 10.
Suggestions to help along the way. im close just not understanding the loop

Attachments Capture.PNG 24.98 KB
2
Contributors
1
Reply
18
Views
2 Months
Discussion Span
Last Post by john_111
0

<td Bgcolor=<?php echo $row['PMStatus']?>
this says the Bgcolor= the $row['PMStatus']?
And bgcolor is not a valid style name, and you should be using css to style it anyway.
Also you havn't included you <table> or </table> tabs

You should building it like this.
<table>
then the loop echoing each row (<tr>) with its contents in their <td>
then outside the loop close the table
</table>

But
<td Bgcolor=<?php echo $row['PMStatus']?>></td>
should be
<td><?php echo $row['PMStatus']?></td>

THEN when it works, make it pretty with your css, by giving the table a class and styling the rows and columns once, in the css.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.