REOL Posted August 17, 2006 Share Posted August 17, 2006 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 --><?phpif( $_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><?phpforeach ($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] Quote Link to comment Share on other sites More sharing options...
REOL Posted August 17, 2006 Author Share Posted August 17, 2006 up Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 17, 2006 Share Posted August 17, 2006 I for one havn't really got a clue what you are asking, perhaps it is just me. Also, enclose your code in full php tags(<?php ?>) So we can see it with syntax highlighting. Makes it a lot easier on the eye. Quote Link to comment Share on other sites More sharing options...
Jenk Posted August 17, 2006 Share Posted August 17, 2006 Just remove the top table?! Quote Link to comment Share on other sites More sharing options...
REOL Posted August 17, 2006 Author Share Posted August 17, 2006 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_idso the output would be like:property_id (1)spacespacespacespaceproperty_id (2)spacespacespaceAND NOTproperty_id (1)spaceproperty_id (1)spaceproperty_id (2)spaceproperty_id (2)space Quote Link to comment Share on other sites More sharing options...
REOL Posted August 17, 2006 Author Share Posted August 17, 2006 anyone? Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 [quote]i wanted to use the whereAdd funtion i believe?as well as fetch() ? ?[/quote]What are you talking about? Could you please be a bit more descriptive in your problem... and stop bumping your thread! Quote Link to comment Share on other sites More sharing options...
REOL Posted August 17, 2006 Author Share Posted August 17, 2006 testpage is here:http://reol.com/slgreen/test.phpjust choose a property or district and search. youll see the print_r and results below it.. and from there youll know what im talking about.thanks for your time.-ps Quote Link to comment Share on other sites More sharing options...
REOL Posted August 17, 2006 Author Share Posted August 17, 2006 last time im uppin this ! please any assistance?-ps Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 17, 2006 Share Posted August 17, 2006 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! ;) Quote Link to comment Share on other sites More sharing options...
REOL Posted August 18, 2006 Author Share Posted August 18, 2006 ive tried several ways, but its not working :/ is there another way? or someone help me out here?thanks Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 Change your [b]foreach()[/b] loop to a [b]for()[/b] loop so you can track what loop iterationyou 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]<?phpfor($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! ;) Quote Link to comment Share on other sites More sharing options...
REOL Posted August 18, 2006 Author Share Posted August 18, 2006 tried to put it in but something doesnt seem to work.ill keep crackin at it and i think you got me in the right direction.thanks for all help!-ps Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 18, 2006 Share Posted August 18, 2006 What is not working? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.