I am having a heck of a time. Hopefully someone can offer some help.
It should be simple....
I have two tables....one called residential and one called features.
I have a query for residential that is doing everything I need it to do...now I need to setup a second query for features.
Basically, all I need to do is get data from the features table into this script. For example....where I have NEED CODE FIELD FROM FEATURES HERE I need to have the code field from my features table, and where I have NEED LONG TEXT FIELD FROM FEATURES HERE I need the long text field from my features table.
This piece of code splits a 255 character string into 3 characters. This three character code should match a code in code field of the features table. The result of the three character code should be the LONG TEXT FIELD
My code looks like this: If you can help me setup the second query that goes to the features table....I will almost be done with my script! Thank you.....
<?
session_start();
?>
<?
$username="XXX";
$password="XXX";
$database="xxx";
mysql_pconnect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM residential WHERE Id like '$Id'";
$result=mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
?>
<?
if(mysql_numrows($result) == '0') {
echo "Sorry, no results were found...";
} else {
// display results here
}
?>
<?
while ($row = mysql_fetch_array($result)) // this will grab the results from query
{
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle">
image here
</td>
<td width="100%" valign="top">
<table border="0" width="100%" cellspacing="1">
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="1">
<tr>
<td width="70%" bgcolor="#FFFF99">Listing ID Number(MLS) - <b><? echo $row['Id']; ?></b> Price - <b>$<? echo $row['list_price']; ?></b></td>
<td width="30%" bgcolor="#FFFF99">Town - <b><? echo $row['town']; ?></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="1">
<tr>
<td width="25%" align="right" bgcolor="#FFFFE6">Year Built:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['year_built']; ?></b></td>
<td width="25%" align="right" bgcolor="#FFFFE6">Rooms:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['rooms']; ?></b></td>
</tr>
<tr>
<td width="25%" align="right" bgcolor="#FFFFE6">Lot Size:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['lot_size_acres']; ?></b></td>
<td width="25%" align="right" bgcolor="#FFFFE6">Bed Rooms:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['bedrooms']; ?></b></td>
</tr>
<tr>
<td width="25%" align="right" bgcolor="#FFFFE6">Taxes:</td>
<td width="25%" bgcolor="#FFFFE6"><b>$<? echo $row['taxes']; ?></b></td>
<td width="25%" align="right" bgcolor="#FFFFE6">Full Baths:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['baths']; ?></b></td>
</tr>
<tr>
<td width="25%" align="right" bgcolor="#FFFFE6">Tax Years:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['tax_years']; ?></b></td>
<td width="25%" align="right" bgcolor="#FFFFE6">Seasonal:</td>
<td width="25%" bgcolor="#FFFFE6"><b><? echo $row['seasonal']; ?></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%"><strong>Room Dimensions: </strong>Master Bedroom: <? echo $row['bd1_size']; ?>,
Bedroom 2: <? echo $row['bd2_size']; ?>, Bedroom 3: <? echo $row['bd3_size']; ?>, Bedroom 4: <? echo $row['bd4_size']; ?>, Dining: <? echo $row['dr_size']; ?>, Kitchen: <? echo $row['kt_size']; ?></td>
</tr>
<tr>
<td width="100%">
<hr>
</td>
</tr>
<tr>
<td width="100%"><? echo $row['remark1']; ?><br>
<center><a href="java script:history.go(-1);">Back to previous results</a><br><br>
<i><b><center>E-Mail us for more info on this listing: <a href="mailto:listings@century21highview.com%20?SUBJECT=Enquiry
on MLS#
<? echo $row['Id']; ?>">test</a></b></i></center></font></p>
</td>
</tr>
</table>
<?
$split_features = "$row[features]";
$i = 0;
?>
<table cellspacing="0" cellpadding="0">
<?
for ($i = 0; $i <= 85; $i += 3)
{
?>
<tr>
<td>
<?
if ((substr($split_features,$i ,3)) == "NEED CODE FIELD FROM FEATURES HERE")
{
echo "NEED LONG TEXT FIELD FROM FEATURES HERE";
}
else
{
echo substr($split_features,$i ,3);
}
?>
</td>
</tr>
<?
}
?>
</table>
</table>
</td>
</tr>
<?
}
?>
</body>
</html>