Jump to content

While loop echoing data twice??


advancedfuture

Recommended Posts

I'm having a problem with my code. It queries the database then I use a while loop to print the rows out.. the problem is it is echoing each row 2x? What am I doing wrong?

 

<?
include 'connection.php';

//GET URL DATA FROM THE URL
$city = htmlspecialchars($_GET['city']);
$state = htmlspecialchars($_GET['state']);
$query = "SELECT * FROM Listings WHERE city ='$city' AND state ='$state'";
$results = mysql_query($query);

//START PAGE HTML HEADERS
echo "<html><head>";

//STAR WHILE LOOP TO CYCLE THROUGH ALL THE RESULTS FROM THE QUERY.
//SPIT OUT EACH RESULE ON THEIR OWN LINE.
while($rows = mysql_fetch_array($results))
{
$idnumber = $rows['idnumber'];
$studioprice = $rows['studioprice'];
$price3 = $rows['price3'];
echo "Property Id Number ".$idnumber."<br>";
echo "1 Bedroom - 3 bedroom Ranging From".$studioprice." - ".$price3."<br><br>";
}
//CLOSE THE HTML PAGE
echo "</html></head>";
?>

Link to comment
https://forums.phpfreaks.com/topic/102237-while-loop-echoing-data-twice/
Share on other sites

Archived

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

×
×
  • 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.