Jump to content

displaying a query


REOL

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]
Link to comment
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]
Link to comment
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
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.