(2016-04-11, 01:53 PM)Euan T Wrote: Hi,
Can you paste the code you added please?
The data I'm selecting is not from mybb_ tables. I forgot to mention that my forum is integrated to the codeigniter project. I work on advertisement portal and I need to have topped ads displayed on the top of the forum.
Here's the code:
$query = $db->query("
SELECT dlzka_topovania, nazov_obchodu
FROM settings
WHERE settings_id = 1
");
while($settings = $db->fetch_array($query)) {
$dlzka_topovania = $settings['dlzka_topovania'];
$nazov_obchodu = $settings['nazov_obchodu'];
}
$query = $db->query("
SELECT inzerat_id, datum_do
FROM inzerat_top
ORDER BY inzerat_id
");
$i = 0;
while($ads = $db->fetch_array($query)) {
if(strtotime($ads['datum_do']) > strtotime("now")) {
$top_ads[$i] = $ads['inzerat_id'];
$i++;
}
}
$query = "
SELECT inzerat_id, meno, mesto, datum_narodenia, verified, date_added, topovanie
FROM inzerat
WHERE inzerat_id IN (";
$values = "";
for($i = 0; $i < count($top_ads); $i++)
{
$values .= $top_ads[$i];
if($i < count($top_ads) - 1) {
$values .= ", ";
}
}
$query .= $values;
$query .= ")
AND status = 'active' AND closed_temporarily = 0 ORDER BY inzerat_id";
$query = $db->query($query);
$i = 0;
$top_ads = "";
require_once 'my_functions/page.php';
require_once 'my_settings/paths.php';
while($topped_ads = $db->fetch_array($query)) {
$ads[$i]['inzerat_id'] = $topped_ads['inzerat_id'];
$ads[$i]['meno'] = $topped_ads['meno'];
$ads[$i]['mesto'] = get_mesto($topped_ads['mesto']);
$ads[$i]['verified'] = $topped_ads['verified'];
$ads[$i]['date_added'] = $topped_ads['date_added'];
$ads[$i]['topovanie'] = $topped_ads['topovanie'];
$date_of_birth = $topped_ads['datum_narodenia'];
$from = new DateTime($date_of_birth);
$to = new DateTime('today');
$ads[$i]['vek'] = (int)$from->diff($to)->y;
//get profile photo
$query_photo = $db->query("
SELECT url
FROM inzerat_photos
WHERE inzerat_id = {$ads[$i]['inzerat_id']}
AND profile_photo = 1
");
while($photo = $db->fetch_array($query_photo)) {
$photo_url = $photo['url'];
}
if(empty($photo_url)) {
$photo_url = 'public/img/nophoto-female.jpg';
}
$top_ads .= '<div class="col-sm-2 ad">';
$top_ads .= '<div class="row user-photo">';
$top_ads .= '<a href="'. ROOT_PATH . '/user/profile/' . $ads[$i]['inzerat_id'] . '"><img src="../' . $photo_url . '" width="150" height="207" alt="user_photo"></a>';
$top_ads .= '</div>';
$top_ads .= '<div class="row user-info">';
$top_ads .= '<p>' . $ads[$i]['meno'] . ' - (' . $ads[$i]['vek'] . ')';
$top_ads .= '<br>';
$top_ads .= $ads[$i]['mesto'] . '</p>';
$top_ads .= '</div>';
$top_ads .= '</div>';
unset($photo_url);
$i++;
}
/*------*/
I added it before this in global:
// Set up some of the default templates
eval('$headerinclude = "'.$templates->get('headerinclude').'";');
eval('$gobutton = "'.$templates->get('gobutton').'";');
eval('$htmldoctype = "'.$templates->get('htmldoctype', 1, 0).'";');
eval('$header = "'.$templates->get('header').'";');