Skip to content

Instantly share code, notes, and snippets.

@ricardosiri68
Last active December 27, 2015 05:29
Show Gist options
  • Save ricardosiri68/7274442 to your computer and use it in GitHub Desktop.
Save ricardosiri68/7274442 to your computer and use it in GitHub Desktop.
seleccionar pais
<?$countries = mysql_query("SELECT * FROM paises");?>
<?$userCountry = mysql_query("SELECT pais FROM users WHERE id = $userId LIMIT 1");?>
<select>
<?if($res and $user):?>
<?$userCountry = mysql_fetch_accoc($userCountry);?>
<?while($country = mysql_fetch_assoc($countries))?>
<option value="<?=$country['nombre']?>"
<?=($userCountry == $country['nombre'])? 'selected=""' : ""; ?> >
<?=$country['nombre']?>
</option>
<?endwhile;?>
<?endif;?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment