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
https://forums.phpfreaks.com/topic/207787-select-var-from-url-if-there/
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.