I need some help. I'm loading a .php file using jquery. the php is a mysql query that pulls all the cities from Alaska. The problem is that I wrote my query a certain way and it seems jquery changes it when it loads it.

state_alaska.php

include 'config.php';

include 'opendb.php';
$AK = mysql_query("SELECT id, city, state FROM city WHERE state ='AK' ORDER BY city ASC") or die(mysql_error()); 

while ( $row = mysql_fetch_array($AK) ) {
    $page = "1";
    echo  "<div class='city'><a href='catagories.php?state=".urlencode($row["state"]) ."&city=".urlencode($row["city"])." &page=".$page."'/>".$row["city"] . "</a></div>";
    }
include 'closedb.php';

Jquery load

    $('#ak').load("state_alaska.php");

Source code

<div id="ak" style="display: block; ">
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Anchorage&amp;page=1"></a>
        Anchorage
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Bethel+&amp;page=1"></a>
        Bethel 
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Fairbanks+&amp;page=1"></a>
        Fairbanks 
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Homer+&amp;page=1"></a>
        Homer
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Juneau&amp;page=1"></a>
        Juneau
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Kenai+&amp;page=1"></a>
        Kenai 
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Ketchikan+&amp;page=1"></a>
        Ketchikan 
    </div>
    <div class="city">
        <a href="catagories.php?state=AK&amp;city=Kodiak+&amp;page=1"></a>
        Kodiak 
    </div>
</div>

In the code I never asked it to display block or to close the </a>'s I dont know why its doing that.. can anyone help?

On line 8, remove the closing slash for the a tag, that's what messes it up. The line should be:

echo  "<div class='city'><a href='catagories.php?state=" . urlencode($row["state"]) . "&city=" . urlencode($row["city"]) . "&page=" . $page . "'>" . $row["city"] . "</a></div>";

or:

echo  "<div class='city'><a href='catagories.php?state=" . urlencode($row["state"]) . "&city=" . urlencode($row["city"]) . "&page=$page'>{$row['city']}</a></div>";