Adamski Posted May 21, 2007 Share Posted May 21, 2007 Hi I'm using this code: <?php include("whmcs/configuration.php"); include("whmcs/includes/functions.php"); $link = mysql_connect($db_host,$db_username,$db_password); mysql_select_db($db_name); $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC"; $result=mysql_query($query); while($data = mysql_fetch_array($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = $data["announcement"]; $date = fromMySQLDate($date); echo("<div class='left_date'>$date</div><div class='left_comment'>$title</div><div class='hr'><hr /></div>"); } ?> To include the announcement title and date on my front page but I need some help. 1. Date is displayed 2007-5-21. How can I change this to be Day and Month (preferably name of month)? 2. How can I make either the date or the title a link to go to the announcements page? I've worked that one out as you can only link to page and not announcements within page! 3. Is there a way of just pulling the 3 most recent announcements? Thanks muchly for any help, mysql is a definate weak spot for me! Adam 0 Quote Link to comment Share on other sites More sharing options...
DataHosts Posted May 21, 2007 Share Posted May 21, 2007 http://www.whmcs.com/forums/viewtopic.php?t=123&start=0&postdays=0&postorder=asc&highlight=announcements It is an older version to show announcements on homepage, but it works. I use it and can modify to show what I wish...check it out 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 21, 2007 Author Share Posted May 21, 2007 Thanks datahosts, Pretty much the script I'm using (which I got from the knowledgebase). I've just chopped out the announcement detail. There was nothing in that post that helped with my questions and the dowload isn't available anymore. I've found out about MySQL date_format but not sure how to implement it so I will keep hunting. Thanks, Adam 0 Quote Link to comment Share on other sites More sharing options...
DataHosts Posted May 21, 2007 Share Posted May 21, 2007 I will play around as well with this. I have been meaning to get on it and make it easier, but time has not permitted....keep you updated on my progress 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 21, 2007 Author Share Posted May 21, 2007 Thanks I have changed $date = fromMySQLDate($date); for $date = date("js M); which displays how I want, but only todays date. I assume because it isn't referencing the database. I will continue playing. To be honest the date's I can live with as I know I will get round that but it's only displaying the last 3 annoucnements that has me AD 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted May 21, 2007 Share Posted May 21, 2007 you can get more info about date formats from http://www.php.net/date As far as limiting the number of announcements, try changing this line" $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC"; to $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 3"; ?> 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 21, 2007 Author Share Posted May 21, 2007 Ok got it : replace $date = fromMySQLDate($date); with $date = date("jS M", strtotime($date)); And works a treat obviously "jS M" can be replaced with how you want your date formatted! Ad 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 21, 2007 Author Share Posted May 21, 2007 adding LIMIT 0,3 to the end of the query line lets you just pull the last 3 announcements. Ad 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted May 21, 2007 Share Posted May 21, 2007 for urls, try this: echo("<div class='left_date'>$date</div><div class='left_comment'>[url='whmcs/announcements.php']$title[/url]</div><div class='hr'><hr /></div>"); 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 21, 2007 Author Share Posted May 21, 2007 Thans MAC - didn't see your post about LIMIT Ad 0 Quote Link to comment Share on other sites More sharing options...
FavHost Posted August 14, 2007 Share Posted August 14, 2007 How about a code that shows like this: Date - Title Teaser of subject ...READ MORE Having a teaser of the announcement subject (maye 10 words long) followed by a ...Read More Any suggestions? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted August 14, 2007 Share Posted August 14, 2007 How about a code that shows like this: Date - Title Teaser of subject ...READ MORE Having a teaser of the announcement subject (maye 10 words long) followed by a ...Read More Any suggestions? if your using smarty, u can use the modifier called "truncate" 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.