css - Adding Borders to HTML Table of SQL Query Results -
trying add borders , column headings table of results sql query. results display fine there no headings or borders on table, looks jumble of results.
</div> <div id="section"> <h2>upcoming events</h2> <?php $connection = mysqli_connect('localhost', 'c3437691', 'chelsea27', 'c3437691'); ?> <?php $query = "select * event"; $result=mysqli_query($connection, $query); echo "<table>"; while ($row=mysqli_fetch_assoc($result)){ ?> <tr> <td><?php echo $row['event_name']?></td> <td><?php echo $row['event_location']?></td> <td><?php echo $row['event_date']?></td> <td><?php echo $row['ticket_price']?></td> <td><?php echo $row['ticket_stock']?></td> </tr> <?php } ?> </div>
you need explicitly output table headers -- iterating on results mysql not include column names.
after opening <table>
before while
loop, add following:
<tr> <th>event name</th> <th>event location</th> <th>event date</th> <th>ticket price</th> <th>ticket stock</th> </tr>
if want add borders table, should apply css table.
Comments
Post a Comment