Not being able to see your code and not knowing exactly what problem you are
having I can only throw a few guesses here.  If you could elaborate more on
what you are expecting and what you are getting that would be a big help.

$country_sql = "select countryname, countryid from TBL_COUNTRY";

You don't use the value of countryname anywhere in your it

    if ($country_query = mssql_query($country_sql)) {

What is this statement intended to do?  Typical when a query is formed PHP
gives the query an integer id.  But that ID is allocated by PHP and if you
add a new query earlier in the code later on the ID for this query will most
likely change...which then will make it not equal what you're expecting it
to this case $country_query.

Also on a further note you need to use == instead of = otherwise PHP will
assume the statement is always true.

       while ($myrow = mssql_fetch_array($country_query))
          if ($country == $myrow["countryid"]) {
               print "<option value=" . $myrow["countryid"] . " selected>" .
$countryid . "</option>";
         } else {
               print "<option value=" . $myrow["countryid"] . ">" .
$countryid . "</option>";

Your while statement is missing a { ....was this code working when you used
Also unless you need PHP returning the success of printing the text you're
better off using echo instead of print.

Based on what I see this code may be what you're looking for

$country_sql = 'SELECT countryid FROM TBL_COUNTRY';
while ($myrow = mssql_fetch_row($country_query)) {
        echo "<option value=$myrow[0]";
        if ($country == $myrow[0]) { echo " selected>$myrow[0]</option>"; }
        else { echo ">$myrow[0]</option>"; }


Craig Vincent

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to