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