Jump to content


Photo

displaying a query


  • Please log in to reply
5 replies to this topic

#1 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 22 August 2006 - 02:30 PM

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?


<?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;
?>


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 22 August 2006 - 02:34 PM

<?php= $result['X'] ?>

to <?php echo $result['X']; ?>
follow me on twitter @PHPsycho

#3 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 22 August 2006 - 02:39 PM

yes i know i just put it like that so you can see the code properlly!

-ps


#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 August 2006 - 02:58 PM

Chnage this:
?>
<?php
foreach ( $results as $result ) {
?>

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

foreach ( $results as $result ) {
?>


#5 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 22 August 2006 - 03:07 PM

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


#6 REOL

REOL
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 22 August 2006 - 03:48 PM

anyone know how to display two outputs, then add a row, and then continue with the array/

-ps




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users