Thanks - good to know your script will work on all pages.
Thanks guys for all your work![]()
Thanks - good to know your script will work on all pages.
Thanks guys for all your work![]()
This is brilliant. Saves me using an external news system and keeps a lot of my stuff in one place.
Thanks a lot.
Unless Matt changed the table associated with the announcements, yes, it will work. I highly doubt this was changed though.
well my rss2html script can't pull information any more... with the previous setup I have
Care to post the script?
It's the free one out there... google search it.
I've gotten in trouble for sharing links before.. so...
That's alright, if you want to post the code I'll check it out.
http://www.rss2html.com/ is the script he's talking about.
@jordanriane / mywhmcs.com
Frontend Webdeveloper (Currently Available)
Anyone get a similar error?
News & announcements: view more'; if($x) echo '
There are no new announcements.
'; ?>
I was able to get it working but taking from another method and coming up with this:
Code:{php} // truncate the text to only 65 chars, add ... to the end function truncate($text) { $text = substr($text,0,200); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } include("support/dbconnect.php"); include("support/includes/functions.php"); $query = "SELECT * FROM tblannouncements WHERE published='on' ORDER BY date DESC LIMIT 0,3"; $result = mysql_query($query); while ($data = mysql_fetch_array($result)) { $id = $data["id"]; $date = $data["date"]; $title = $data["title"]; $announcement = truncate($data['announcement']); $date = fromMySQLDate($date); echo'<div style="border:solid 1px #e8e8e8; padding:5px;background-color:#f7f7f7;">'.$date.' - <strong><a href="announcements.php?id='.$id.'">'.$title.'</a></strong><p class="sfont2"> '.$announcement.' <a href="announcements.php?id='.$id.'">...more</a></p></div><p>'; } {/php}
Of course as stated - you will need to change appropriate URLs and HTML.
Excellent little snippet. Thanks alot!
This sounds like a great solution however I tried it and got a blank page
I created a page called news.php
I posted this code:
-----------------------------------------------------------
<?
$x=1; // requested edit
// truncate the text to only 65 chars, add ... to the end
function truncate($text) {
$text = substr($text,0,60);
$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
$limit = 2;
require '/home/trouble/public_html/billing/configuration.php';
$link = mysql_connect($db_host,$db_username,$db_password);
mysql_select_db($db_name);
$result = mysql_query("SELECT * FROM tblannouncements WHERE published='on' ORDER BY id DESC LIMIT ".$limit);
while($data = mysql_fetch_array ($result))
{
$id = $data['id'];
$date = $data['date'];
$announcement = truncate($data['announcement']);
$date = formatdate($date);
echo'<p><span>'.$date.'</span> - '.$announcement.' <a href="../billing/announcements.php?id='.$id.'"><img src="/images/more.gif" alt="more info" /></a></p>';
echo'<hr />';
$x=false;
}
if(!$x) echo '<p>News & announcements: <a href="../billing/announcements.php">view more</a></p>';
if($x) echo '<p>There are no new announcements.</p>';
?>
----------------------------------------------
Am I suppose to do something with this:
-----------------------------------------
require '/home/user/public_html/billing/configuration.php';
$link = mysql_connect($db_host,$db_username,$db_password);
mysql_select_db($db_name);
-----------------------
Am I suppose to change out the values to match my site??
/home/user/ - should that be something else?
$db_host
$db_username
$db_password
$db_name
Are those suppose to be something else?
this script works great for me on latest version 3.8.1