Hi,

The following code is working without errors:

<table>
                    <tr>
                        <td>Booking No.</td>
                        <td>Driver Id</td>
                        <td>Time Booked</td>
                        <td>From</td>
                        <td>Pick Up Time</td>
                        <td>To</td>
                        <td>No. of Passengers</td>
                        <td>Distance</td>
                        <td>Cost</td>
                    </tr>
                    <?php
                        $stmt = $dbh->prepare("SELECT * FROM Booking
                          WHERE cust_id = '$username'
                          ");
                        $stmt->execute();
                        
                        
                        while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
                            echo "<tr><td>".$row['booking_no']."</td>".
                                 $row['driver_id']."</td>".
                                 $row['time_booked']."</td>".
                                 $row['pick_up_dest']."</td>".
                                 $row['pick_up_time']."</td>".
                                 $row['arrive_dest']."</td>".
                                 $row['no_of_passengers']."</td>".
                                 $row['distance']."</td>".
                                 $row['cost']."</td></tr>";
                        }
                    ?>
                </table>

However rather than the field headings being displayed above the rows each piece of data is appearing above the field headings apart from the booking_no. The output is like this:

driverneil2012-01-28 01:00:00Oxford2012-01-28 01:30:00London21540.00
Booking No. 	Driver Id 	Time Booked 	From 	Pick Up Time 	To 	No. of Passengers 	Distance 	Cost
000001

Anyone know why this is happening?

Also is there a better way of outputting this data using PDOs?

Thanks in advance.

You are missing <td> 's.

You are missing <td> 's.

LOL what a silly mistake, guess that is what tiredness does to you!

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.