0

I am outputting my database data in a table in HTML. I want the last to output a bit more to the right. But if I use inline css styling I am getting a parse error:

my code:

<table class="scroll">
    <thead style="background-color: #99E1D9; color: #705D56;">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Last Update</th>
            <th style="padding-left: 30%;">Status</th>
        </tr>
    </thead>
        <tbody id="hoverTable">
                <?php

                    $connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
                    mysql_select_db('patientdb');

                    $query = "SELECT id, name, date, status FROM clients"; //You don't need a ; like you do in SQL
                    $result = mysql_query($query);

                    while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
                    echo "<tr> 
                            <td>" . $row['id'] . "</td> 
                            <td>" . $row['name'] . "</td> 
                            <td>" . $row['date'] . "</td>

<td style="padding-left: 30%;">" . $row['status'] . "</td>

                         </tr>";  //$row['index'] the index here is a field name
                    }

                    mysql_close(); //Make sure to close out the database connection
                ?>
</tbody>
</table> 

The Error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /webpage/composition/login/portal/portal.php on line 174

Is there another way to output the last <td> about 30% apart from the third <td>?

MSD
  • 171
  • 3
  • 15

2 Answers2

2

You need to escape your strings on the echo.

"</td><td style="padding-left: 30%;">"

try

"</td><td style=\"padding-left: 30%;\">"
aconnelly
  • 662
  • 1
  • 6
  • 13
1

I would suggest trying the following

Double and Single Quote

"<td style='padding-left: 30%;'>"

or

Escape Quote

"<td style=\"padding-left: 30%;\">"