} $sql = "SELECT * FROM ads WHERE course_key=" . "'" . mysql_real_escape_string($context->getCourseKey()) . "' " . "ORDER BY created_at DESC"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if ($message) { echo '<p style="color:red;">' . $message . "</p>\n"; } if (mysql_num_rows($result) == 0) { echo "<p>No Ads available for '" . $context->getCourseName() . "'"; echo ' (<a title="New Ad" href="' . $selfp . 'action=add">Create New Ad</a>)' . "\n"; } else { ?> <table style="width: 100%"> <tr><th style="width: 70%"> <?php $title = $context->getResourceTitle(); if ($title === false) { echo 'Title'; } else { echo $title; } ?> (<a title="New Ad" href="<?php echo $selfp; ?> action=add">Create New Ad</a>) </th><th>Date</th><th>Action</th></tr> <?php while ($row = mysql_fetch_array($result)) { ?>