Jump to content

Archived

This topic is now archived and is closed to further replies.

REOL

displaying a query

Recommended Posts

i want to have the "<h1>" tags only display once. I am having trouble setting an array for it.

can someone help me out?

also how do i display a reuslt twice, add a row, then display again?


[code]<?php
include_once( "format.php" );
$city = $_GET['city'];

if ($city) :
$query = "SELECT * FROM properties WHERE city='$city' ORDER BY propid";
$results = pgdbsql( $query, "my_table" );
?>
<?php
foreach ( $results as $result ) {
?>

<h1>Properties in <?php= $result['city'] ?>, <?php= $result['state']?></h1>
<table cellspacing=2 cellpadding=1 border=0>
  <tr>
<td vAlign=top><a href="property_overview.php?propid=<?php= $result['propid'] ?>">
<?php
if(file_exists("img_property/{$result['propid']}_thumb.gif")) {
?>
<img src="img_property/<?php= $result['propid'] ?>_thumb.gif" border=0>
<?php } else { ?>
<img src="img_property/prop_na.jpg" border=0>
<?php } ?>
</a></td>
<td class=tiny vAlign=top><span class=tiny_red><?php= $result['name'] ?></span><br /><?php= $result['address'] ?><p><img src="img_property/icon_<?php= $result['type'] ?>.gif" border=0></td>
  </tr>
</table>
<?php
}
endif;
?>[/code]

Share this post


Link to post
Share on other sites
yes i know i just put it like that so you can see the code properlly!

-ps

Share this post


Link to post
Share on other sites
Chnage this:
[code]?>
<?php
foreach ( $results as $result ) {
?>

<h1>Properties in <?php= $result['city'] ?>, <?php= $result['state']?></h1>[/code]
To this:
[code]
echo '<h1>Properties in ' . $results['city'] . ', ' . $results['state'] . '</h1>';

foreach ( $results as $result ) {
?>[/code]

Share this post


Link to post
Share on other sites
thanks!

it didnt originally work but this worked instead

echo '<h1>Properties in ' . $results[0]['city'] . ', ' . $results[0]['state'] . '</h1>';

...

know how to display two results, then add a row then display the next two results after that?

-ps

Share this post


Link to post
Share on other sites
anyone know how to display two outputs, then add a row, and then continue with the array/

-ps

Share this post


Link to post
Share on other sites

×

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.