Jump to content

Announcements to an external page


netzone

Recommended Posts

To show announcements to an external page you should use this part of code.

 

<?php

// Connects to your Database 
mysql_connect("host", "user", "password") or die(mysql_error()); // host: your host or IP, user: database user, password: your database user's password
mysql_select_db("database") or die(mysql_error());// database of whmcs

$x=1;
// truncate the text to only 65 chars, add ... to the end
function truncate($text) {
$text = substr($text,0,65);
$text = substr($text,0,strrpos($text,' '));
$text = $text." ... ";
return $text;
}
// format the date to mm/dd/yyyy
function formatdate($date) {
$year = substr ($date, 0, 4);
$month = substr ($date, 5, 2);
$day = substr ($date, 8, 2);
return $month.'/'.$day.'/'.$year;
}
// limit the number of announcements to return. Default is 6
$limit = 6;

$result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit);
while($data = mysql_fetch_array ($result))
{
$id = $data['id'];
$title = $data['title'];
$date = $data['date'];
$announcement = truncate($data['announcement']);
$date = formatdate($date);
echo'<div>» <font color=#5C6C7B>'.$date.' <a href="http://www.your_domain.com/announcements.php?id='.$id.'" class=heading2>'.$title.'</a></font><br>'.$announcement.' <a href="http://www.your_domain.com/announcements.php?id='.$id.'"><img src="http://www.your_domain.com/images/viewdetails.gif" border="0" alt="view more" /></a>';
echo'<hr /></div>';

}

?>

 

You can modify the html to fit it to your website :)

 

Edit: i think i have posted to a wrong section :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated