/    Sign up×
Community /Pin to ProfileBookmark

Too tired to find the problem…

I’m trying to feed a menu from database, from a table that have the fields Localidad, Localidad1, Localidad2, Localidad3, Localidad4. The criteria is to take them where Inmo=$Inmo.
What’s wrong in this code?
Menu is empty!

[code=php]
<?
$base=””;
$tabla=””;
$conexion=mysql_connect(“”,””,””);
mysql_select_db($base,$conexion);
$pegar1 = “SELECT Localidad, Localidad1, Localidad2, Localidad3, Localidad4 FROM $tabla WHERE (Inmo=’$Inmo’)”;
?>
<select name=”Localidad” size=”1″ class=”B”>
<option value=”-1″></option>
<?
$resultado1 = mysql_db_query($base,$pegar1)or die (mysql_error());
while ($registro[‘Localidad’] = mysql_fetch_row($resultado1))
{
foreach($registro[‘Localidad’] as $opciones){
}
?>
<option value=<? echo $opciones; ?>> <? echo $opciones;
}
?> </option>
</select>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@JonaNov 17.2003 — [font=arial]Try using mysql_fetch_assoc() instead of mysql_fetch_row(), or if you must use mysql_fetch_row() use mysql_fetch_row($resultadol, MYSQL_ASSOC)

That is, assuming you have your $conexion variable set properly (with the database, username and password, which I'm guessing you took out for obvious raesons).[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@-kde-Nov 17.2003 — Don't complicate your life ?

[code=php]
<?
mysql_connect("","","");
mysql_select_db($base);
$res = mysql_query("SELECT * FROM $tabla WHERE Inmo='$Inmo'");
?>
<select name="Localidad" size="1" class="B">
<option value="-1"></option>
<?
while ($data = mysql_fetch_array($res)) {
echo "<option value='{$data['opciones']}'>{$data['opciones']}</option>";
}
?>
</select>
[/code]
×

Success!

Help @Perfidus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...