netzone Posted September 18, 2008 Share Posted September 18, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.