amuck-landowner

Announcements link in WHMCS on page

NodeWest-Dan

New Member
I am implementing an announcements list in my sites footer which uses WHCMS' announcements page and the code they have on their website.  I can't for the life of me figure out how to make the titles into URLS.  Would anyone know how to modify the code?  There is no URL section inside the tblannouncements.

Code:
<?php
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 = $data["announcement"];
$date = fromMySQLDate($date);
echo '<p><font color="#cccccc">'.$date.'</font> - <b>'.$title.'</b><br />'.$announcement.'</p>';
}
?>
 

SC-Daniel

New Member
Verified Provider
Here you go :) This should work...

Code:
<?php

include("support/dbconnect.php");
include("support/includes/functions.php");

$whmcsUrl = "https://url.to.whmcs.com";

$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 = $data["announcement"];
    $date = fromMySQLDate($date);
    
    echo '<p><font color="#cccccc">' . $date . '</font> - <b><a href="' . $whmcsUrl . '/announcements.php?id=' . $id . '">' . $title . '</a></b><br />' . $announcement . '</p>';
    
}

?>
 

NodeWest-Dan

New Member
Thank you very much right as you posted this I was just remembering to write it off the ID.  This is what I went with


Code:
<?php
include("support/dbconnect.php");
include("support/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 = $data["announcement"];
$url = $data["url"];
$date = fromMySQLDate($date);
echo '<p><font color="#cccccc">'.$date.'</font> - <a href="support/announcements.php?id='.$id.'"><b>'.$title.'</b></a></p>';
}
?>
 
Last edited by a moderator:

Francisco

Company Lube
Verified Provider
You don't need to define things as variables to use it in the HTML part.

You can just do echo "blah " . $row['stuff'];

Other than that, cool stuff :)

Francisco
 
Last edited by a moderator:
Top
amuck-landowner