PDA

View Full Version : listing_browse



para
03-29-2004, 05:06 AM
Is it possible to create one more sort column in listing_browse.php like Title, but it's name should be User (the name people enter while they are getting registered)/

awddesign
03-29-2004, 09:43 AM
Hi

Yes this can be done.

Need to see the site so i can send you the code.

Al

para
03-29-2004, 12:07 PM
can't show you the site online, sorry, cause it's not uploaded yet, but i can post the part of my listing_browse.php right in a place where listing begins



// this is the main SQL that grabs the listings
// basic sort by title..
if ($sortby == "")
{
$sort_text = "";
$order_text = "ORDER BY ID DESC";
}
elseif ($sortby == "listingname")
{
$sort_text = "";
$order_text = "ORDER BY Title $sorttype";
}
// BEGIN NEW CODE
elseif ($sortby == "price")
{
$sortby = make_db_extra_safe($sortby);
$sort_text = "WHERE (field_name = $sortby)";
$order_text = "ORDER BY field_value +0 $sorttype";
}
// END NEW CODE
else
{
$sortby = make_db_extra_safe($sortby);
$sort_text = "WHERE (field_name = $sortby)";
$order_text = "ORDER BY field_value $sorttype";
}
if (($sorttype == "") || ($sorttype == "ASC"))
{
$sorttype = "DESC";
}
else
{
$sorttype = "ASC";
}

$guidestring_with_sort = $guidestring_with_sort.$guidestring;

$sql = "SELECT * from " . $config[table_prefix] . "temp $sort_text GROUP BY ID $order_text";
$recordSet = $conn->Execute($sql);
if ($recordSet === false)
{
log_error($sql);
}

$num_rows = $recordSet->RecordCount();
if ($num_rows > 0)
{
echo "<table width=\"100%\" border=\"0\"><tr><td width=\"18\"><a href=\"".$config['baseurl']."members/savesearch.php?$guidestring\" class=\"menu_left\"><img src=\"".$config['baseurl']."gfx/save_listing.gif\" width=\"16\" height=\"16\" border=\"0\"></a></td><td width=\"100\"><a href=\"".$config['baseurl']."members/savesearch.php?$guidestring\" class=\"menu_left\">$lang[save_this_search]</a></td><td width=\"18\"><a href=\"".$config['baseurl']."print.php\" class=\"menu_left\"><img src=\"".$config['baseurl']."gfx/print.gif\" width=\"18\" height=\"17\" border=\"0\"></a></td><td width=\"100\"><a href=\"".$config['baseurl']."print.php\" class=\"menu_left\">Print version</a></td><td width=\"*\">&amp;nbsp;</td></tr></table><!-- startprint -->";
next_prev($num_rows, $cur_page, $guidestring_with_sort); // put in the next/previous stuff

// build the string to select a certain number of listings per page
$limit_str = $cur_page * $config[listings_per_page];
$resultRecordSet = $conn->SelectLimit($sql, $config[listings_per_page], $limit_str );
if ($resultRecordSet === false)
{
log_error($sql);
}

?>

<table border="<?php echo $style[form_border] ?>" cellspacing="<?php echo $style[form_cellspacing] ?>" cellpadding="<?php echo $style[form_cellpadding] ?>" width="100%" class="form_main" align="center">
<tr>
<?php
if (($sortby == "listingname") ||($sortby == ""))
{
$sorttypestring = "sorttype=$sorttype&amp;amp;";
}
?>

<?php
// grab browsable fields
$sql = "SELECT field_caption, field_name FROM " . $config[table_prefix] . "listingsFormElements WHERE (display_on_browse = 'Yes') AND (field_type <> 'textarea') ORDER BY rank";
$recordSet = $conn->Execute($sql);
$num_columns = $recordSet->RecordCount();
// Add Title as a search link
$field_caption = "Адрес";
$field_name = "listingname";
if ($sortby != $field_name)
{
$sorttypestring = "";
}
else
{
$sorttypestring = "sorttype=$sorttype&amp;amp;";
}
echo "<td width=\"16\" bgcolor=\"#eeeeee\" class=\"nav_bar_left\"></td><td align=\"center\" bgcolor=\"#eeeeee\" class=\"nav_bar_left\"><b><a href=\"$PHP_SELF?sortby=$field_name&amp;amp;$sorttypestring$g uidestring\"><b>$field_caption</b></a></b></td>";

while (!$recordSet->EOF)
{
$field_caption = make_db_unsafe ($recordSet->fields[field_caption]);
$field_name = make_db_unsafe ($recordSet->fields[field_name]);
if ($sortby != "'$field_name'")
{
$sorttypestring = "";
}
else
{
$sorttypestring = "sorttype=$sorttype&amp;amp;";
}
echo "<td align=\"center\" bgcolor=\"#eeeeee\" class=\"nav_bar_left\"><b><a href=\"$PHP_SELF?sortby=$field_name&amp;amp;$sorttypestring$g uidestring\"><b>$field_caption</b></a></b></td>";
$recordSet->MoveNext();
} // end while
$num_columns = $num_columns + 2; // add one for the image
?>
</tr>
<tr>
<td colspan="<?php echo $num_columns ?>" height="1" bgcolor="#c0c0c0"></td>
</tr>

<?php
$count = 0;
while (!$resultRecordSet->EOF)
{
// alternate the colors
if ($count == 0)
{
$count = $count +1;
}
else
{
$count = 0;
}

$Title = make_db_unsafe ($resultRecordSet->fields[Title]);
$current_ID = $resultRecordSet->fields[ID];
echo "<tr><td align=\"left\" class=\"search_row_$count\" width=\"16\"><a href=\"".$config['baseurl']."listingview.php?listingID=$current_ID\"><img src=\"".$config['baseurl']."gfx/view_listing.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"View Info\"></a></td>";
echo "<td align=\"left\" class=\"search_row_$count\"><b><a href=\"".$config['baseurl']."listingview.php?listingID=$current_ID\" class=\"menu_left\">$Title</a></b></td>";

// echo "<tr>";

// grab the listing's image
$sql2 = "SELECT thumb_file_name FROM " . $config[table_prefix] . "listingsImages WHERE listing_id = $current_ID ORDER BY rank";
$recordSet2 = $conn->SelectLimit($sql2, 1, 0);
if ($recordSet2 === false)
{
log_error($sql2);
}
$num_images = $recordSet2->RecordCount();
if ($num_images == 0)
{
if ($config[show_no_photo] == "yes")
{
//echo "<td class=\"search_row_$count\" align=\"center\"><img src=\"images/nophoto.gif\" border=\"1\" alt=\"no photo\"></td>";
echo "<td class=\"search_row_$count\" align=\"center\"><a href=\"listingview.php?listingID=$current_ID\"><img src=\"images/nophoto.gif\" border=\"1\" alt=\"no photo\"></a></td>";
}
else
{
// echo "<td class=\"search_row_$count\">&amp;nbsp;</td>";
echo "";
}
}
while (!$recordSet2->EOF)
{
$thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name != "")
{
// gotta grab the image size
$imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name");
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$shrinkage = $config[thumbnail_width]/$imagewidth;
$displaywidth = $imagewidth * $shrinkage;
$displayheight = $imageheight * $shrinkage;
// echo "<td class=\"search_row_$count\">&amp;nbsp;</td>";
//echo "<td class=\"search_row_$count\" align=\"center\"><a href=\"listingview.php?listingID=$current_ID\">";
//echo "<img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\" alt=\"$thumb_file_name\"></a></td>";
} // end if ($thumb_file_name != "")
$recordSet2->MoveNext();
} // end while

// grab the rest of the listing's data
$sql2 = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $current_ID) AND (" . $config[table_prefix] . "listingsFormElements.display_on_browse = 'Yes') AND (" . $config[table_prefix] . "listingsFormElements.field_type <> 'textarea') AND (" . $config[table_prefix] . "listingsDBElements.field_name = " . $config[table_prefix] . "listingsFormElements.field_name)) ORDER BY " . $config[table_prefix] . "listingsFormElements.rank";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false)
{
log_error($sql2);
}
while (!$recordSet2->EOF)
{
$field_value = make_db_unsafe ($recordSet2->fields[field_value]);
$field_type = make_db_unsafe ($recordSet2->fields[field_type]);
echo "<td align=\"center\" class=\"search_row_$count\">";

if ($field_type == "select-multiple" OR $field_type == "option" OR $field_type == "checkbox")
{
// handle field types with multiple options

$feature_index_list = explode("||", $field_value);
while (list($feature_list_Value, $feature_list_item) = each ($feature_index_list))
{
echo "$feature_list_item<br>";
} // end while
} // end if field type is a multiple type

elseif ($field_type == "price")
{
//$field_value = ereg_replace('[^0-9]', '', $field_value);
//echo "$config[money_sign]".number_format($field_value, 2, '.', ',');
$sql3 = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $current_ID) AND (" . $config[table_prefix] . "listingsFormElements.field_type <> 'textarea') AND (" . $config[table_prefix] . "listingsDBElements.field_name = " . $config[table_prefix] . "listingsFormElements.field_name)) AND (" . $config[table_prefix] . "listingsDBElements.field_name = 'status') ORDER BY " . $config[table_prefix] . "listingsFormElements.rank";
$recordSet3 = $conn->Execute($sql3);
if ($recordSet3 === false)
{
log_error($sql3);
}
$status = make_db_unsafe ($recordSet3->fields[field_value]);
$recordSet3->Close();
$money_amount = international_num_format($field_value);
if ($status == 'Sold')
{
echo "<s>";
echo money_formats($money_amount);
echo "</s><br><span style=\"color:red;\"><b>Продано</b></span>";
}
elseif ($status == 'Pending')
{
echo money_formats($money_amount);
echo "<br><span style=\"color:green;\"><b>ОТЛОЖЕНО</b></span>";
}
else
{
echo money_formats($money_amount);
}
} // end elseif
elseif ($field_type == "number")
{
echo international_num_format($field_value);
} // end elseif
elseif ($field_type == "url")
{
echo "<a href=\"$field_value\" target=\"_new\">$field_value</a>";
}
elseif ($field_type == "email")
{
echo "<a href=\"mailto:$field_value\">$field_value</a>";
}
else
{
echo "<font style=\"font: normal 11px tahoma\">$field_value</font>";
} // end else

echo "</td>";
$recordSet2->MoveNext();
} // end while


echo "</tr>";
// deal with text areas, like descriptions
$sql2 = "SELECT " . $config[table_prefix] . "listingsDBElements.field_value, " . $config[table_prefix] . "listingsFormElements.field_type FROM " . $config[table_prefix] . "listingsDBElements, " . $config[table_prefix] . "listingsFormElements WHERE ((" . $config[table_prefix] . "listingsDBElements.listing_id = $current_ID) AND (" . $config[table_prefix] . "listingsFormElements.display_on_browse = 'Yes') AND (" . $config[table_prefix] . "listingsFormElements.field_type = 'textarea') AND (" . $config[table_prefix] . "listingsDBElements.field_name = " . $config[table_prefix] . "listingsFormElements.field_name)) ORDER BY " . $config[table_prefix] . "listingsFormElements.rank";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false)
{
log_error($sql2);
}
while (!$recordSet2->EOF)
{
$field_value = make_db_unsafe ($recordSet2->fields[field_value]);
$field_caption = make_db_unsafe ($recordSet2->fields[field_caption]);
// echo "<tr><td colspan=\"$num_columns\" class=\"search_row_$count\">$field_value</td></tr>";
echo "<td colspan=\"$num_columns\" class=\"search_row_$count\">$field_value</td></tr>";
$recordSet2->MoveNext();
} // end while


$resultRecordSet->MoveNext();
} // end while

awddesign
03-29-2004, 03:50 PM
Hi

That will not help..

Show me the MSQL bump:

default_listingsformelements

I can check it on my system server at awdcars.co.uk

Al

para
03-30-2004, 08:50 AM
oohhh... ok ... here



# phpMyAdmin MySQL-Dump
# http://www.phpmyadmin.net/ (download page)
#
# Host: localhost
# Time: Mar 30 2004, 16:39
# Server Version: 4.0.11
# PHP: 4.3.2
# DB : `catalog`
# --------------------------------------------------------

#
# Table `default_listingsformelements`
#

CREATE TABLE default_listingsformelements (
ID int(11) NOT NULL auto_increment,
field_type varchar(20) NOT NULL default '',
field_name varchar(20) NOT NULL default '',
field_caption varchar(80) NOT NULL default '',
default_text text NOT NULL,
field_elements text NOT NULL,
rank int(11) NOT NULL default '0',
required char(3) NOT NULL default '',
location varchar(15) NOT NULL default '',
display_on_browse char(3) NOT NULL default 'No',
searchable int(10) unsigned NOT NULL default '0',
search_type varchar(10) default NULL,
search_label varchar(50) default NULL,
search_step int(11) NOT NULL default '0',
display_priv char(3) NOT NULL default 'No',
PRIMARY KEY (ID),
KEY idx_searchable (searchable)
) TYPE=MyISAM;

#
# Table Dump `default_listingsformelements`
#

INSERT INTO default_listingsformelements VALUES (30, 'select', 'rayon', 'District', '', '||Cetner||North-West||North-South||South-West||South||East||Other', 2, 'Yes', 'top_left', 'No', 1, 'fpulldown', 'District', 0, 'No');
INSERT INTO default_listingsformelements VALUES (24, 'text', 'area', 'Area, m*2.', '', '', 4, 'No', 'top_left', 'Yes', 0, '', '', 0, 'No');
INSERT INTO default_listingsformelements VALUES (25, 'select', 'plan', 'Appt. type', '', '||new.||old.||bulding.||gsn.||little.||better.||e mpty.', 5, 'Yes', 'top_left', 'Yes', 1, 'fpulldown', 'Appt. Type', 0, 'No');
INSERT INTO default_listingsformelements VALUES (26, 'text', 'floor_type', 'Floor, House type', '', '', 6, 'Yes', 'top_left', 'Yes', 0, '', '', 0, 'No');
INSERT INTO default_listingsformelements VALUES (27, 'text', 'price', 'Price, USD', '', '', 7, 'Yes', 'top_left', 'Yes', 1, 'minmax', 'Price (USD)', 10, 'No');
INSERT INTO default_listingsformelements VALUES (28, 'text', 'firm', 'Firm', '', '', 8, 'No', 'top_left', 'Yes', 0, '', '', 0, 'No');
INSERT INTO default_listingsformelements VALUES (29, 'select', 'type', 'Type', '', '||One Room||Two Rooms||Three Rooms||More then 3 Rooms', 3, 'Yes', 'top_left', 'No', 0, '', '', 0, 'No');
INSERT INTO default_listingsformelements VALUES (31, 'select', 'city', 'City', '', '||NY||LA||Other', 1, 'Yes', 'top_left', 'No', 1, 'fpulldown', 'City', 0, 'No');

awddesign
03-30-2004, 09:56 AM
Hi

Great..

working on it Now