this is a very messy code, i tried to copy from one to other. it displays images and the name and last name of the person. it does it vertically and i need to show let say in two columns so the third image and the name last name falls to next row and etc. would you please help me with hthis?
thank you
function showfavorites_run_template_user_fields($tag = '') {
$strip = explode("_", $tag);
$quantity = $strip[3];
$tag = "$strip[0]_$strip[1]_$strip[2]";
switch ($tag) {
case 'addon_showfavorites_viewnum':
$data = showfavorites_view($quantity);
break;
default:
$data = '';
break;
}
return $data;
}
// Addon Specific Function
function showfavorites_view($quantity) {
global $conn, $config, $db_type;
require_once($config['basepath'] . '/include/misc.inc.php');
require_once($config['basepath'] . '/include/listing.inc.php');
require_once($config['basepath'] . '/include/images.inc.php');
$misc = new misc();
$display = '';
$user_id = $_GET['user'];
if ($db_type == 'mysql') {
$rand = 'RAND()';
} else {
$rand = 'RANDOM()';
}
$sql = "SELECT listingsdb_id FROM " . $config['table_prefix'] . "userfavoritelistings WHERE userdb_id=" . $user_id . " ORDER BY " . $rand;
$recordSet = $conn->SelectLimit($sql, $quantity, 0);
if ($recordSet === false) {
$misc->log_error($sql);
}
if ($recordSet->RecordCount() > 0) {
$display .= '<div id="addon_favorites">';
$display .= '<p>Arkadaş Listesi:</p>';
$display .= '<ul>';
while (!$recordSet->EOF) {
$listingsdb_id = $misc->make_db_unsafe($recordSet->fields['listingsdb_id']);
$listingSQL = '';
$listingSQL .= "(listingsdb_id = " . $listingsdb_id . ") AND (listingsdb_active = 'yes')";
if ($config['use_expiration'] == 1) {
$listingSQL .= " AND (listingsdb_expiration > " . $conn->DBDate(time()) . ")";
}
$sql2 = "SELECT userdb_id FROM " . $config['table_prefix'] . "listingsdb WHERE " . $listingSQL;
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false) {
$misc->log_error($sql2);
}
$listing_userdb_id = $misc->make_db_unsafe($recordSet2->fields['userdb_id']);
//$agent_thumbnail = image_handler::renderUserImages($listing_userdb_id);
$agent_thumbnail = renderUserImages($listing_userdb_id );
$listing_agent_firstName = listing_pages::getListingAgentFirstName($listingsdb_id);
$listing_agent_lastName = listing_pages::getListingAgentLastName($listingsdb_id);
$listing_agent_link = listing_pages::getListingAgentLink($listingsdb_id);
$display .= '<p>' . $agent_thumbnail . ' </p><li><a href="' . $listing_agent_link . '" title="' . $listing_agent_firstName . ' ' . $listing_agent_thumbnail . ' ' . $listing_agent_lastName . '">' . $listing_agent_thumbnail . ' ' . $listing_agent_firstName . ' ' . $listing_agent_lastName . '</a></li>';
$recordSet->MoveNext();
}
$display .= '</ul>';
$display .= '</div>';
} else {
// DO NOTHING - THIS USER HAS NO FAVORITES
}
return $display;
}
function renderUserImages($user)
{
// grabs the listings for a given user
global $conn, $config, $lang;
require_once($config['basepath'] . '/include/misc.inc.php');
$misc = new misc();
$display = '';
$user = $misc->make_db_safe($user);
// grab the images
$sql = "SELECT userimages_id, userimages_caption, userimages_thumb_file_name FROM " . $config['table_prefix'] . "userimages WHERE userdb_id = $user ORDER BY userimages_rank LIMIT 0, 1";
$recordSet = $conn->Execute($sql);
if ($recordSet === false) {
$misc->log_error($sql);
}
$num_images = $recordSet->RecordCount();
if ($num_images > 0) {
while (!$recordSet->EOF) {
$caption = $misc->make_db_unsafe ($recordSet->fields['userimages_caption']);
$thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_thumb_file_name']);
// $file_name = $misc->make_db_unsafe ($recordSet->fields['userimages_file_name']);
$imageID = $misc->make_db_unsafe ($recordSet->fields['userimages_id']);
// gotta grab the image size
$imagedata = GetImageSize("$config[user_upload_path]/$thumb_file_name");
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$max_width = $config['thumbnail_width'];
$max_height = $config['thumbnail_height'];
$resize_by = $config['resize_thumb_by'];
$shrinkage = 1;
if (($max_width == $imagewidth) || ($max_height == $imageheight)) {
$displaywidth = $imagewidth;
$displayheight = $imageheight;
} else {
if ($resize_by == 'width') {
$shrinkage = $imagewidth / $max_width;
$displaywidth = $max_width;
$displayheight = round($imageheight / $shrinkage);
} elseif ($resize_by == 'height') {
$shrinkage = $imageheight / $max_height;
$displayheight = $max_height;
$displaywidth = round($imagewidth / $shrinkage);
} elseif ($resize_by == 'both') {
$displayheight = $max_height;
$displaywidth = $max_width;
}
}
//$display .= "<a href=\"index.php?action=view_user_image&image_id=$imageID\"> ";
//$display .= "<a href=\"$config[baseurl]/index.php?action=view_user&user=$userID\">";
//$display .= '<p>' . $agent_thumbnail . ' </p><li><a href="' . $listing_agent_link . '" title="' . $listing_agent_firstName . ' ' . $listing_agent_thumbnail . ' ' . $listing_agent_lastName . '">' . $listing_agent_thumbnail . ' ' . $listing_agent_firstName . ' ' . $listing_agent_lastName . '</a></li>';
//$display .= "<img src=\"$config[user_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\"></a><br /> ";
$display .= "<img src=\"$config[user_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\"></a>";
$display .= "<b>$caption</b><br />";
$recordSet->MoveNext();
}
}else {
$display .= "<img src=\"images/nophoto_1.gif\" alt=\"\" /><br />";
} // end ($num_images > 0)
return $display;
} // end function renderUserImages
?>