News
require("/var/www/html/www/dbconn.inc.php");
$conn = connectdb("api_companies");
$SQL = ($_GET['link'] != '') ? "SELECT * FROM `news` WHERE `co_name` = \"".$_SERVER['company']."\" AND `company`='yes' AND `status`='approved' AND `url`='".$_GET['link']."';" : "SELECT * FROM `news` WHERE `co_name` = \"".$_SERVER['company']."\" AND `company`='yes' AND `status`='approved' ORDER BY `date` DESC";
$news = mysql_query($SQL, $conn) or die(mysql_error().$SQL);
$row_news = mysql_fetch_assoc($news);
do {
unset($class, $image);
$class = ($row_news['photos'] > 0) ? "box_w_image" : "box";
if ($class == "box_w_image"){
$SQLa = "SELECT * FROM `news_photos` WHERE `newsitem` = '".$row_news['id']."' ORDER BY `headline` ASC;";
$images = mysql_query($SQLa, $conn);
$row_images = mysql_fetch_assoc($images);
$image = '';
if ($row_images['headline'] == 'yes'){
$src = "http://www.apigroupinc.com/images/releases/".$row_images['newsitem']."/".$row_images['path'];
$credit = ($row_images['credit']) ? '
'.$row_images['credit'].'' : '' ;
$caption = ($row_images['credit']) ? '
'.$row_images['caption'].'' : '';
$extra = ($_GET['limit'] == 1) ? "height='100'" : "";
$image = '
!['.$row_images['caption'].']('.$src.')
';
$credit;
$caption;
$image = "\n\t".'
'.$image.$credit.$caption.'
';
$image .= "\n\t".'';
}
}
$body = ($_GET['limit'] == 1 && strlen($row_news['teaser']) > 30) ? nl2br(strip_tags($row_news['teaser']))."
Read more" : nl2br($row_news['body']);
$body = ($_GET['limit'] == 1 && strlen($row_news['teaser']) < 30) ? (substr(strip_tags($row_news['body']), 0, 250)."...
Read more") : $body;
echo '
';
if(!isset($_GET['headonly'])) {
echo '
'.$image.'
'.$row_news['head1'].'
'.date('F d, Y', strtotime($row_news['date'])).'
'.$body.'
';
} else {
echo '
'.$row_news['head1'].' - ' . date('F d, Y', strtotime($row_news['date'])) . '
';
}
echo '
';
}while($row_news = mysql_fetch_assoc($news));
?>