Jump to content

select var from url if there


steelbut

Recommended Posts

Hopefully someone can help, I'm new to PHP and it seems like a large knowledge base here.

 

I have a web site where the user would choose there country and the info in added to the url to a submit page.

 

And example would be http://www.peb-buildings.com/quote.php?building_country_id=Angola

 

I need Angola to be inserted as selected as the first option if a country is present.  Then if empty the rest of the code pulls up the option of the US then you pick a state and so on.  The code is below.  Thanks a head of time!  Larry

 

<td class=field-text><select name="building_country_id">

  <?php

$query = "select * from countries order by country_name";

$result = mysql_query($query);

$sqlError = mysql_error();

if (!empty($sqlError)) {

logError($sqlError,$query,__LINE__);

}

while ($row = mysql_fetch_array($result)) {

?>

    <option value="<?php echo $row['country_id'] ?>"<?php echo ($row['country_id'] == 1000 ? " selected" : "") ?>><?php echo $row['country_name'] ?></option>

  <?php

}

?>

    </select></td>

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.