PDA

View Full Version : Address instead of Title



Jade
10-21-2003, 12:34 PM
I want to show the Address of the listings instead of the Title in 2 places. 1st is in userview.php under, "Other listings from this user". In my site, the Title is just a combination of codes & letters for the office's database, so showing a street address would be more user friendly. I know the code to change this is in style.php at this function:


function userListings($user)
{
// produces the rest of the listings for users

global $conn, $lang, $config;
$user = make_db_extra_safe($user);
echo "<b>Other listings from this user&#58;</b><ul>";
$sql = "SELECT ID, Title FROM " . $config&#91;table_prefix&#93; . "listingsDB WHERE user_ID = $user";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$ID = $recordSet->fields&#91;ID&#93;;
$Title = make_db_unsafe &#40;$recordSet->fields&#91;Title&#93;&#41;;
echo "<li> <a href=\"listingview.php?listingID=$ID\">$Title</a></li>";
$recordSet->MoveNext&#40;&#41;;
&#125;
echo "</ul>";
&#125; // end function userListings


If I change all occurances of Title to Address though, it's just blank.

The other place I want to do the same is in edit_my_listings.php. Again, below the Listing Number, it shows the Title. It'd be nicer if it was the address.

Please help! Thanks in advance. :wink:

Andre
10-21-2003, 01:58 PM
Unless the database structure has changed from the version I'm using, address is not maintained in the listingsDB table, it's in the listingsDBElements table. I'm surprised you're not getting an sql error message.

Try this. Beware, I haven't tested it.



function userListings&#40;$user&#41;
&#123;
// produces the rest of the listings for users

global $conn, $lang, $config;
$user = make_db_extra_safe&#40;$user&#41;;
echo "<b>Other listings from this user&#58;</b><ul>";
$sql = "SELECT a.ID, Title,field_name FROM " . $config&#91;table_prefix&#93; . "listingsDB a," . $config&#91;table_prefix&#93; . "listingsDBElements b
WHERE a.user_ID = $user and a.ID = listing_id and field_name='address' ";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$ID = $recordSet->fields&#91;ID&#93;;
$Title = make_db_unsafe &#40;$recordSet->fields&#91;Title&#93;&#41;;
$adddress = make_db_unsafe&#40;$recordSet->fields&#91;field_name&#93;&#41;;
echo "<li> <a href=\"listingview.php?listingID=$ID\">$address</a></li>";
$recordSet->MoveNext&#40;&#41;;
&#125;
echo "</ul>";
&#125; // end function userListings

HTH

Jade
10-21-2003, 02:31 PM
Thanks for the code! It generates an error though:

Parse error: parse error, expecting `'{'' in /home/virtual/site59/fst/var/www/html/openrealty/template/vertical-menu/style.php on line 1450

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/virtual/site59/fst/var/www/html/openrealty/template/vertical-menu/style.php:1450) in /home/virtual/site59/fst/var/www/html/openrealty/include/main.php on line 4

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virtual/site59/fst/var/www/html/openrealty/template/vertical-menu/style.php:1450) in /home/virtual/site59/fst/var/www/html/openrealty/include/main.php on line 4

Also, I have 1 more question... how come a link like this:

listing_browse.php?featured=Y

doesn't show a page with my featured listings like it used to? What's the proper link to see the featured listings on a page, not a column?

Andre
10-21-2003, 03:23 PM
Try it now. If it still gives a parse error then switch address from 'address' to \"address\".

Jade
10-22-2003, 12:06 PM
Hrm, same silly error. You'd think it'd at least give me a brand new, cool error!

Andre
10-22-2003, 05:38 PM
That answer should be right. I just tested and didn't get any parse errors. Only thing is i gave you the wrong field.

You can see example at http://www.home2sell.net/userview/aferree/

Here's same code with correct field. Be sure to check for spaces when cutting and pasting.



function userListings&#40;$user&#41;
&#123;
// produces the rest of the listings for users

global $conn, $lang, $config;
$user = make_db_extra_safe&#40;$user&#41;;
echo "<b>Other listings from this user&#58;</b><ul>";
$sql = "SELECT a.ID, Title,field_value
FROM " . $config&#91;table_prefix&#93; . "listingsDB a," .
$config&#91;table_prefix&#93; . " listingsDBElements b
WHERE a.user_ID = $user and a.ID = listing_id and field_name='address' ";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
while &#40;!$recordSet->EOF&#41;
&#123;
$ID = $recordSet->fields&#91;ID&#93;;
$Title = make_db_unsafe &#40;$recordSet->fields&#91;Title&#93;&#41;;
$address = make_db_unsafe&#40;$recordSet->fields&#91;field_value&#93;&#41;;
echo "<li>
<a href=\"listingview.php?listingID=$ID\">$address</a></li>";
$recordSet->MoveNext&#40;&#41;;
&#125;
echo "</ul>";
&#125; // end function userListings

Jade
10-24-2003, 02:15 PM
Awesome! It was spacing and I had to fix the 3 d's on address on this line:

$adddress = make_db_unsafe($recordSet->fields[field_value]);

Works now, thanks Andre! :D