Help regarding member country select
Posted: Wed Nov 01, 2006 5:53 pm
Hi there,
I'm currently still learning PHP, enjoying every minute of it. However I've come across a stumbling block and abit puzzled as to whats wrong exactly. Would be wonderful if someone can shed some light and let me know whats wrong.
Here the current code, im still testing, so forgive me if some vairable names seems strange or something.
Now the select works for all intensive purposes. Basically its for a member profile page, where members can update theyre profile, country being one of them.
Its correctly retrieving the list of countries from my SQL DB and displaying them to the user in a select drop down box. The Update function is also working and checking shows the country prefix, for example (Brazil = br) is being entered into theyre SQL field in the users profile which is "country".
The problem being though, it should be displaying the users current country in the select box, pre selected if you would, when they first load up the "edit profile" page.
At the moment, its just displaying the x: prefix, with no country selected like it should.
Would be ever so grateful if someone could point out whats exactly wrong and where, I've been stuck with this for a while now!
Cheers for any help in advance.
I'm currently still learning PHP, enjoying every minute of it. However I've come across a stumbling block and abit puzzled as to whats wrong exactly. Would be wonderful if someone can shed some light and let me know whats wrong.
Here the current code, im still testing, so forgive me if some vairable names seems strange or something.
Code: Select all
<?
$sqlqueryold = mysql_query("SELECT name,prefix FROM countries WHERE prefix='$info[country]'");
$infoOC = mysql_fetch_array($sqlqueryold, MYSQL_ASSOC);
print "<OPTION value=\"$infoOC[prefix]\" selected=\"selected\">x: $infoOC[name]</OPTION>";
$sqlquery = "SELECT name,prefix FROM countries ORDER BY name ASC";
$result = mysql_query($sqlquery);
$number = mysql_num_rows($result);
$i = 0;
if ($number < 1) {
print "<p class=\"StandardText\">No countries!</p>";
}
else {
while ($number > $i) {
$co_name = mysql_result($result,$i,"name");
$co_prefix = mysql_result($result,$i,"prefix");
print "<OPTION value=\"$co_prefix\">$co_name</OPTION> \n";
$i++;
}
}
?>Its correctly retrieving the list of countries from my SQL DB and displaying them to the user in a select drop down box. The Update function is also working and checking shows the country prefix, for example (Brazil = br) is being entered into theyre SQL field in the users profile which is "country".
The problem being though, it should be displaying the users current country in the select box, pre selected if you would, when they first load up the "edit profile" page.
At the moment, its just displaying the x: prefix, with no country selected like it should.
Would be ever so grateful if someone could point out whats exactly wrong and where, I've been stuck with this for a while now!
Cheers for any help in advance.