1

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?

2
  • Does the output format have to look like a regular calendar? Say google's calendar? Commented Apr 7, 2010 at 20:57
  • Are You going to use rowspan= or colspan= in HTML table cels? Commented Apr 7, 2010 at 21:03

5 Answers 5

2

You can mix your result from PHP into HTML code:

<table>
<?php
foreach ($results as result){
  echo '<tr><td>'.$result->field.'</td></tr>';
}
?>
</table>
Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

0

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.

Comments

0

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

Comments

0
<table>
<?php while ($row = mysql_fetch_assoc($result)) {?>
   <tr>
      <td>
           Event ID = <?php $row['id'] ?> <br />
           Event Day = <?php $row['day]?> <br/>
           Event Start = <?php $row['start_date']?> <br/>
           Event End = <?php $row['end_date']?> 
      </td>
   </tr>
<?php } ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.