[Freerealty] featured.php missing database name?
Scott Wang
scott at scottscomputing.com
Tue Apr 26 07:54:05 MST 2005
Argh! Another hair-puller. I just spent an hour trying to get the featured
listings to work and I think I found the problem.
I had to add the ' $db. ' to the two mysql_query lines in order for it to
stop throwing errors. I looked and couldn't figure out how the mysql_query
knew which database it was querying. After I did that, the two listings
showed up correctly, images and all.
This is the content of featured.php, with the two $db.'s that I added in
red.
//EXAMPLE CODE:
//handles the listing of featured properties
//Adding random rotation of images and a limit
//Check to see if $noimages is set
$result = mysql_query("SELECT distinct * from $db.".$table_prefix."homes
WHERE featured = 'Y' AND status != 'Held' ORDER BY RAND() LIMIT $limit",
$link);
while ($a_row = mysql_fetch_array($result) )
{
//add commas to price
$a_row['price'] = number_format ($a_row['price']);
$a_row['title'] = stripslashes($a_row['title']);
echo "<p /><a
href=\"./propview.php?view=$a_row[id]\"><b>$a_row[title]</b></a><BR>";
//select images connected to a given listing
$query = "SELECT * FROM $db.".$table_prefix."tbl_Files WHERE prop_num =
$a_row[id] LIMIT 1";
$output = mysql_query("$query",$link);
$count = 0;
while ($image_row = mysql_fetch_array($output) )
{
print "<a href=\"propview.php?view=$a_row[id]\"><img
src='image.php?Id=$image_row[id_files] &image=thumb' border=1 width=100
alt=\"Photo\"></a><br>";
$count++;
}
if($count == 0)
{
print "<a href=\"./propview.php?view=$a_row[id]\"><img
src=\"./images/nophoto.gif\" border=1 width=100 alt=\"View
Listing\"></a><br>";
}
// print "$a_row[beds] beds/$a_row[baths] baths<BR> \$$a_row[price]<BR> <P
/>";
}
- Scott Wang
Scott's Computing
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4372 bytes
Desc: not available
Url : http://lists.rwcinc.net/pipermail/freerealty/attachments/20050426/2944cfff/winmail.bin
More information about the FreeRealty
mailing list