Check for no links returned stops error

git-svn-id: http://svn.automattic.com/wordpress/trunk@151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
mikelittle 2003-06-03 22:42:13 +00:00
parent 6a80aa6395
commit 73c4f8cfad
1 changed files with 16 additions and 14 deletions

View File

@ -453,20 +453,21 @@ switch ($action) {
// echo "$sql"; // echo "$sql";
$links = $wpdb->get_results($sql); $links = $wpdb->get_results($sql);
foreach ($links as $link) { if ($links) {
$short_url = str_replace('http://', '', $link->link_url); foreach ($links as $link) {
$short_url = str_replace('www.', '', $short_url); $short_url = str_replace('http://', '', $link->link_url);
if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1); $short_url = str_replace('www.', '', $short_url);
if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1);
if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...';
$link->link_name = stripslashes($link->link_name); $link->link_name = stripslashes($link->link_name);
$link->category = stripslashes($link->category); $link->category = stripslashes($link->category);
$link->link_rel = stripslashes($link->link_rel); $link->link_rel = stripslashes($link->link_rel);
$image = ($link->link_image != null) ? 'Yes' : 'No'; $image = ($link->link_image != null) ? 'Yes' : 'No';
$visible = ($link->link_visible == 'Y') ? 'Yes' : 'No'; $visible = ($link->link_visible == 'Y') ? 'Yes' : 'No';
++$i; ++$i;
$style = ($i % 2) ? ' class="alternate"' : ''; $style = ($i % 2) ? ' class="alternate"' : '';
echo <<<LINKS echo <<<LINKS
<tr valign="middle"$style> <tr valign="middle"$style>
<td><strong>$link->link_name</strong><br /> <td><strong>$link->link_name</strong><br />
Description: $link->link_description</td> Description: $link->link_description</td>
@ -479,7 +480,8 @@ echo <<<LINKS
<td><input type="submit" name="delete" onclick="document.forms['links'].link_id.value='$link->link_id'; document.forms['links'].action.value='Delete'; return confirm('You are about to delete this link.\\n \'Cancel\' to stop, \'OK\' to delete.'); " value="Delete" class="search" /></td> <td><input type="submit" name="delete" onclick="document.forms['links'].link_id.value='$link->link_id'; document.forms['links'].action.value='Delete'; return confirm('You are about to delete this link.\\n \'Cancel\' to stop, \'OK\' to delete.'); " value="Delete" class="search" /></td>
</tr> </tr>
LINKS; LINKS;
} }
}
?> ?>
</table> </table>
</form> </form>