views:

118

answers:

4

So i am working on a project and need some advice.

I have a MySQL database that stores events, i know how to code this functionality in PHP but im just stuck of a few specifics.

As the project that I am creating is a timetable, the most important attributes are the day of the event, starting time and finishing time.

Once i have read this data from the MYSQL database using my PHP script, how do i go about inserting these events in to a html timetable?

Lets say i have record like below in my events table:

Event ID = 01
Event Day = Monday
Event Start = 12:00
Event End = 14:00

How would I then put that into a html table, bearing in mind that i may have mutiple events for a day?

A: 

mysql_fetch_array($result) iterates the rows from your result. Just do something like this:

while ($row = mysql_fetch_array($result)) {
    echo $row['fieldname'];
}

The above code would display every item in the result's column named "fieldname". Use HTML to format the results however you like.

Hurpe
A: 

Are you having trouble determining how the PHP mixes with the HTML in this situation? If so:

<table>
<thead>
    <tr>
        <th>Event ID</th>
        <th>Event Day</th>
        <!-- etc... -->
    </tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_assoc($resultSet)) { ?>
    <tr>
        <td><!-- Event ID row data --></td>
        <td><!-- Event Day row data --></td>
        <!-- etc... -->
    </tr>    
<? } ?>
</tbody>
</table>
webbiedave
A: 

You can mix your result from PHP into HTML code:

<table>
<?php
foreach ($results as result){
  echo '<tr><td>'.$result->field.'</td></tr>';
}
?>
</table>
Ronaldo Junior
A: 

u can do something like this http://monket.net/wiki-v2/Image:MonketCalendarLarge.png

nik