Jump to content

help, very easy stuff


REOL

Recommended Posts

This form finds property availabilities from a database and displays it.

currently it outputs the *TOP TABLE(property)* and *BOTTOM TABLE (spaces available in the property)*  together on each result. but i only want display the *BOTTOM TABLE* multiple times for each space.

hope i can get some quicck help on this.


[code]

<!--results -->
<?php
if( $_GET['district_id'] && $_GET['district_id'][0] != 'all' )
{
$district_id = $_GET['district_id'];
$minRentSq = $_GET['minimum_rent'];
$maxRentSq = $_GET['maximum_rent'];
$minSq = $_GET['minimum_space'];
$officeBool = $_GET['isRetail'];
$preBuiltBool = $_GET['isPrebuilt'];
$sort_field = $_GET['sort_field'];
$spaces = getSpacesByDistrict( $district_id, $minRentSq, $maxRentSq, $minSq, $officeBool, $preBuiltBool, $sort_field);
echo "<pre>";
print_r( $spaces );
echo "</pre>";
}
else if( $_GET['property_id'] && $_GET['property_id'][0] != 'all' )
{
$property_id = $_GET['property_id'];
$minRentSq = $_GET['minimum_rent'];
$maxRentSq = $_GET['maximum_rent'];
$minSq = $_GET['minimum_space'];
$officeBool = $_GET['isRetail'];
$preBuiltBool = $_GET['isPrebuilt'];
$sort_field = $_GET['sort_field'];
$spaces = getSpacesByProperty( $property_id, $minRentSq, $maxRentSq, $minSq, $officeBool, $preBuiltBool, $sort_field);
echo "<pre>";
print_r( $spaces );
echo "</pre>";
}

?>

<br><br><img src="images/headers/hd_leasing_availableSR.gif" width="523" height="15"><br><br>
<table>
<tr>
<td valign="middle"><input type="image" border="0" alt="Print Results" src="images/misc/printResults.gif"></td>
<td><img src="images/null.gif" width="12"></td>
<td valign="middle">
<span class="foundtext"><?php= count($spaces) ?> leases available at
<?php= $space['address'] ?></span><br><a class="small" href="#top">Refine Search</a></td>
</tr>
</table>

<?php
foreach ($spaces as $space) {
?>
<!-- **************************TOP TABLE************************* -->
<table border="0" width="500" cellpadding="2" cellspacing="1">
<tr>
<td colspan="2"><span class="leaseTitle"><?= $space['address'] ?></span></td>
</tr>
<tr>
<td valign="top" align="right" class="leaseInfo">District:</td>
<td class="leaseText" valign="top"><?php= $space['name'] ?></td>
</tr>
<tr>
<td valign="top" class="leaseInfo" align="right">Contacts:</td>
<td class="leaseText" valign="top"><a class="hplink" href="mailto:howard.tenenbaum@slgreen.com">Howard J. Tenenbaum</a>, 212-216-1685 (SL Green Leasing, LLC)<br><a class="hplink" href="mailto:gary.rosen@slgreen.com">Gary M. Rosen</a>, 212-216-1687 (SL Green Leasing, LLC)<br></td>
</tr>
</table>

<br />
<a href="property.php?id=<?php= $space['id'] ?>"><input class="button" type="button" value="Detailed Property Information" onClick="document.location.href='property.php?id=<?php= $id ?>';"></a>

<br /><br /><br />
<!-- **************************  END TOP TABLE  ************************* -->

<!-- **************************BOTTOM TABLE************************* -->
<table width="500" cellpadding="1" cellspacing="1" border="0">
<tr align="center" bgcolor="#666666">
<td class="smtypeWt">Floor<br><img src="images/gresources/x.gif" alt="SL Green" width="65" height="1" border="0"><br></td>
<td class="smtypeWt">Suite<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Square<br>Feet<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
<td class="smtypeWt">Available<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Rent/SF<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Term<br><img src="images/gresources/x.gif" alt="SL Green" width="45" height="1" border="0"><br></td>
<td class="smtypeWt">Direct/<br>Sublet<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Retail/<br>Office<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
<td class="smtypeWt">Prebuilt<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
</tr>
<?php $bgcolor = ($bgcolor == "#99CCFF") ? "#ccccFF" : "#99CCFF"; ?>
<tr bgcolor="<?php= $bgcolor ?>">
<td align="right" class="smtype" valign="top"><?php= $space['floor']  ?></td>
<td class="smtype" valign="top"><?php= $space['suite'] ?></td>
<td align="right" class="smtype" valign="top"><?php= $space['sqfeet'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $space['availability'] ?>
<img src="/images/null.gif" width="1" height="1"></td>
<td align="right" class="smtype" valign="top"><?php= $space['rentsqfeet'] ?></td>
<td align="right" class="smtype" valign="top"><?php= $space['term'] ?><img src="/images/null.gif" width="1" height="1"></td>
<td align="center" class="smtype" valign="top"><?php= $space['issublet'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $space['isretail'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $space['isprebuilt'] ?></td>
</tr>
<tr bgcolor="<?= $bgcolor ?>"><td align="left" class="smtype" valign="Top" colspan="9">
<?php= $space['notes'] ?></td>
</tr>
<tr bgcolor="<?php= $bgcolor ?>"><td colspan="9" class="smtype"><a class="hplink" href="#" onClick="window.open('floorplan.php?spaceid=$space_id','spacewin','toolbar=no,status=no,directories=no,scrollbars=yes');">Floorplans</a></td>
</tr>
<tr align="center">
<td class="smtype" colspan="9"><img src="images/gresources/x.gif" width="1" height="4" border="0"></td>
</tr>
<?php }  ?>

</table>
<!-- **************************END BOTTOM TABLE************************* -->[/code]
Link to comment
Share on other sites

i wanted to use the whereAdd funtion i believe?

as well as fetch() ? ?

so basically, there are multiple $spaces for each $property_id, i want to show the top table once, which outputs the $property_id ONCE, and show each $space according to the property_id

so the output would be like:

property_id (1)
space
space
space
space

property_id (2)
space
space
space


AND NOT
property_id (1)
space
property_id (1)
space
property_id (2)
space
property_id (2)
space
Link to comment
Share on other sites

Just before your [b]foreach()[/b] loop the prints the spaces, set a variable to track the current property id.

Then after each loop prints a space row, check if the property ID of the next space is the same as the row before it.

If the property ID is the same, just print another space row. If the property ID changes, then update the variable that tracks the current property ID, and print out that property information and it's associated spaces.

Good luck!  ;)
Link to comment
Share on other sites

Change your [b]foreach()[/b] loop to a [b]for()[/b] loop so you can track what loop iteration
you are on, and only print the top table on the first iteration.

You'll notice that with this method you'll access each item in the [b]$spaces[/b] array using [b]$spaces[$i][/b] instead of [b]$space[/b]:

[code]
<?php
for($i=0;$i < count($spaces);$i++){
if( $i == 0 ){
// Print the top table, because we are on the first iteration
?>
<!-- **************************TOP TABLE************************* -->
<table border="0" width="500" cellpadding="2" cellspacing="1">
<tr>
<td colspan="2"><span class="leaseTitle"><?= $spaces[$i]['address'] ?></span></td>
</tr>
<tr>
<td valign="top" align="right" class="leaseInfo">District:</td>
<td class="leaseText" valign="top"><?php= $spaces[$i]['name'] ?></td>
</tr>
<tr>
<td valign="top" class="leaseInfo" align="right">Contacts:</td>
<td class="leaseText" valign="top"><a class="hplink" href="mailto:howard.tenenbaum@slgreen.com">Howard J. Tenenbaum</a>, 212-216-1685 (SL Green Leasing, LLC)<br><a class="hplink" href="mailto:gary.rosen@slgreen.com">Gary M. Rosen</a>, 212-216-1687 (SL Green Leasing, LLC)<br></td>
</tr>
</table>

<br />
<a href="property.php?id=<?php= $spaces[$i]['id'] ?>"><input class="button" type="button" value="Detailed Property Information" onClick="document.location.href='property.php?id=<?php= $spaces[$i]['id']  ?>';"></a>

<br /><br /><br />
<!-- **************************   END TOP TABLE  ************************* -->

<?php
}
// Print the bottom table

<!-- **************************BOTTOM TABLE************************* -->
<table width="500" cellpadding="1" cellspacing="1" border="0">
<tr align="center" bgcolor="#666666">
<td class="smtypeWt">Floor<br><img src="images/gresources/x.gif" alt="SL Green" width="65" height="1" border="0"><br></td>
<td class="smtypeWt">Suite<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Square<br>Feet<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
<td class="smtypeWt">Available<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Rent/SF<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Term<br><img src="images/gresources/x.gif" alt="SL Green" width="45" height="1" border="0"><br></td>
<td class="smtypeWt">Direct/<br>Sublet<br><img src="images/gresources/x.gif" alt="SL Green" width="60" height="1" border="0"><br></td>
<td class="smtypeWt">Retail/<br>Office<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
<td class="smtypeWt">Prebuilt<br><img src="images/gresources/x.gif" alt="SL Green" width="50" height="1" border="0"><br></td>
</tr>
<?php $bgcolor = ($bgcolor == "#99CCFF") ? "#ccccFF" : "#99CCFF"; ?>
<tr bgcolor="<?php= $bgcolor ?>">
<td align="right" class="smtype" valign="top"><?php= $spaces[$i]['floor']  ?></td>
<td class="smtype" valign="top"><?php= $spaces[$i]['suite'] ?></td>
<td align="right" class="smtype" valign="top"><?php= $spaces[$i]['sqfeet'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $spaces[$i]['availability'] ?>
<img src="/images/null.gif" width="1" height="1"></td>
<td align="right" class="smtype" valign="top"><?php= $spaces[$i]['rentsqfeet'] ?></td>
<td align="right" class="smtype" valign="top"><?php= $spaces[$i]['term'] ?><img src="/images/null.gif" width="1" height="1"></td>
<td align="center" class="smtype" valign="top"><?php= $spaces[$i]['issublet'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $spaces[$i]['isretail'] ?></td>
<td align="center" class="smtype" valign="top"><?php= $spaces[$i]['isprebuilt'] ?></td>
</tr>
<tr bgcolor="<?= $bgcolor ?>"><td align="left" class="smtype" valign="Top" colspan="9">
<?php= $spaces[$i]['notes'] ?></td>
</tr>
<tr bgcolor="<?php= $bgcolor ?>"><td colspan="9" class="smtype"><a class="hplink" href="#" onClick="window.open('floorplan.php?spaceid=$spaces[$i]['id']','spacewin','toolbar=no,status=no,directories=no,scrollbars=yes');">Floorplans</a></td>
</tr>
<tr align="center">
<td class="smtype" colspan="9"><img src="images/gresources/x.gif" width="1" height="4" border="0"></td>
</tr>
<?php
}
// Done printing bottom table
?>

</table>
<!-- **************************END BOTTOM TABLE************************* -->

[/code]


Hope this helps!  ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.