[gelöst] mx_userfunctions_options: Länder und Bundesl. werden nicht korrekt aus DB geholt

Begonnen von AlternativeComputing, 11 August 2011, 19:58:03

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 1 Gast betrachten dieses Thema.

AlternativeComputing

Moin Moin,

Sorry, das ich Euch mal wieder Nerven muß ^^

Ich bin gerade am Frontend des osc4pragmaMX Moduls, an der Kunden/Benutzerverwaltung bei und habe nun die mx_userfunctions_options.php entsprechend angepasst. Soweit so gut.

Nun sind da 2 Felder als Pulldownmenü dazugekommen: Zone ID (Bundesländer ID) und Countrys ID (Länder ID).

Der folgende Code ist für die Länder und Bundesländer auswahl zuständig, was auch gut funktioniert bis auf einen kleinen Fehler: Wenn ich nun mich als neuer Benutzer/Kunde Registriere und das Bundesland und Land auswähle wird alles korrekt in die DB gespeichert. Wenn ich nun mich einlogge und meine Daten ändern will, zeigen mir beide Pulldowns die ID 1 per Namen an.


/**
* Info
* Funktion fuer die Laenderauswahl
*/
function CountryIdSelect($user_country_id, $countries_name)
{
    global $prefix;
    $countries = (empty($user_country_id)) ? 0 : (int)$user_country_id;
    $out = "<select name='user_country_id' size='1'>\n";
      $countries = sql_query("select countries_id, countries_name from " . $prefix ."_oscpmx_countries order by countries_name");
      while ($countries_values = sql_fetch_array($countries)) {

$user_country_id = $countries_values['countries_id'];
$countries_name = $countries_values['countries_name'];

    $out .= "<option value='$user_country_id'" . (($user_country_id == 1) ? ' selected="selected"' : '') . " >$countries_name</option>\n";
      }
    $out .= "</select>\n";
    return $out;

}

/**
* Info
* Funktion fuer die Bundeslaender/Bundesstaatenauswahl
*/
function ZoneIdSelect($zone_name, $zone_id)
{
    global $prefix;
    $zone_id = (empty($zone_id)) ? 0 : (int)$zone_id;
    $out = "<select name='user_zone_id' size='1'>\n";
    $zone = sql_query('select zone_id, zone_name from ' . $prefix .'_oscpmx_zones order by zone_id');
      while ($zone_values = sql_fetch_array($zone)) {

$zone_id = $zone_values['zone_id'];
$zone_name = $zone_values['zone_name'];

    $out .= "<option value='$zone_id'" . (($zone_id == 1) ? ' selected="selected"' : '') . " >$zone_name</option>\n";
      }
    $out .= "</select>\n";
    return $out;
}

// die dazugehörigen Zeilen aus der Funktion vkpUserform_option:

         . "<tr valign=\"top\"><td width=\"20%\" bgcolor=\"$bgcolor2\"><b>" . _ZONEID . ":</b></td><td colspan=\"3\" width=\"80%\" bgcolor=\"$bgcolor3\">\n"
         . ZoneIdSelect("user_zone_id", (isset($pvs['user_zone_id'])) ? $pvs['user_zone_id'] : $user_zone_id) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"tiny\">" . _REQUIRED . "</font></td></tr>\n"
         . "<tr valign=\"top\"><td width=\"20%\" bgcolor=\"$bgcolor2\"><b>" . _COUNTRYID . ":</b></td><td colspan=\"3\" width=\"80%\" bgcolor=\"$bgcolor3\">\n"
         . CountryIdSelect("user_country_id", (isset($pvs['user_country_id'])) ? $pvs['user_country_id'] : "") . "<font class=\"tiny\">" . _REQUIRED . "</font></td></tr>\n"



Wo ist nun mein Denkfehler?

My System:

CMS-Version:   pragmaMx 0.1.11.3, 1.33.2.12.2.9.2.3/2010-08-02
PHP-Version:   5.3.7RC4-dev  (PHP-Info)
MySQL-Version:   5.1.46-log
Server-Version:   Apache/2.2.15 (Linux/SUSE)
MfG

Peter

AlternativeComputing

Moin Moin  :BD:

So habs selber hinbekommen :P


/**
* Info
* Funktion fuer die Laenderauswahl
*/
function CountryIdSelect($user_country_id, $countries_name)
{
if (MX_IS_USER) {
    global $prefix, $userinfo, $user_prefix, $uid;

    $countries = (empty($countries_id)) ? 0 : (int)$countries_id;
    $out = "<select name='user_country_id' size='1'>\n";
      $countries = sql_query("select u.user_country_id as user_country_id, oc.countries_id as countries_id, oc.countries_name as countries_name from " . $prefix ."_users as u, " . $prefix ."_oscpmx_countries as oc order by uid, countries_id ASC");
      while ($countries_values = sql_fetch_array($countries)) {

$countries_id = $countries_values['countries_id'];
$countries_name = $countries_values['countries_name'];
$user_country_id = $countries_values['user_country_id'];

    $out .= "<option value='$countries_id'" . (($countries_id == $user_country_id) ? ' selected="selected"' : '') . " >$countries_name</option>\n";
      }
} else {
    global $prefix;
    $countries = (empty($countries_id)) ? 0 : (int)$countries_id;
    $out = "<select name='user_country_id' size='1'>\n";
      $countries = sql_query("select countries_id, countries_name from " . $prefix ."_oscpmx_countries order by countries_name");
      while ($countries_values = sql_fetch_array($countries)) {

$countries_id = $countries_values['countries_id'];
$countries_name = $countries_values['countries_name'];

    $out .= "<option value='$countries_id'" . (($countries_id == 1) ? ' selected="selected"' : '') . " >$countries_name</option>\n";
      }
  }
    $out .= "</select>\n";
    return $out;

}


Andi,

wenn Du bedenken hast, dann meld Dich ^^

Ich lasse den Tread 2 Tage noch offen
MfG

Peter

AlternativeComputing

Hab den Code mal bissel Überarbeitet ^^



/**
* Info
* Funktion fuer die Laenderauswahl
*/
function CountryIdSelect($user_country_id, $countries_name)
{
    global $prefix, $uid;

if (MX_IS_USER) {

    $countries = (empty($countries_id)) ? 0 : (int)$countries_id;
    $out = "<select name='user_country_id' size='1'>\n";
      $countries = sql_query("select u.user_country_id as user_country_id, oc.countries_id as countries_id, oc.countries_name as countries_name from " . $prefix ."_users as u, " . $prefix ."_oscpmx_countries as oc order by uid, countries_id ASC");
      while ($countries_values = sql_fetch_array($countries)) {

$countries_id = $countries_values['countries_id'];
$countries_name = $countries_values['countries_name'];
$user_country_id = $countries_values['user_country_id'];

    $out .= "<option value='$countries_id'" . (($countries_id == $user_country_id) ? ' selected="selected"' : '') . " >$countries_name</option>\n";
      }
} else {

    $countries = (empty($countries_id)) ? 0 : (int)$countries_id;
    $out = "<select name='user_country_id' size='1'>\n";
      $countries = sql_query("select countries_id, countries_name from " . $prefix ."_oscpmx_countries order by countries_name");
      while ($countries_values = sql_fetch_array($countries)) {

$countries_id = $countries_values['countries_id'];
$countries_name = $countries_values['countries_name'];

    $out .= "<option value='$countries_id'" . (($countries_id == 1) ? ' selected="selected"' : '') . " >$countries_name</option>\n";
      }
  }
    $out .= "</select>\n";
    return $out;

}

/**
* Info
* Funktion fuer die Bundeslaender/Bundesstaatenauswahl
*/
function ZoneIdSelect($user_zone_id, $zone_name)
{
    global $prefix, $uid;

if (MX_IS_USER) {

    $zone = (empty($zone_id)) ? 0 : (int)$zone_id;
    $out = "<select name='user_zone_id' size='1'>\n";
      $zone = sql_query("select u.user_zone_id as user_zone_id, oz.zone_id as zone_id, oz.zone_name as zone_name from " . $prefix ."_users as u, " . $prefix ."_oscpmx_zones as oz order by uid, zone_country_id, zone_name ASC");
      while ($zone_values = sql_fetch_array($zone)) {

$zone_id = $zone_values['zone_id'];
$zone_name = $zone_values['zone_name'];
$user_zone_id = $zone_values['user_zone_id'];

    $out .= "<option value='$zone_id'" . (($zone_id == $user_zone_id) ? ' selected="selected"' : '') . " >$zone_name</option>\n";
      }
} else {

    $zone = (empty($zone_id)) ? 0 : (int)$zone_id;
    $out = "<select name='user_zone_id' size='1'>\n";
      $zone = sql_query("select zone_id, zone_name from " . $prefix ."_oscpmx_zones order by zone_country_id, zone_name ASC");
      while ($zone_values = sql_fetch_array($zone)) {

$zone_id = $zone_values['zone_id'];
$zone_name = $zone_values['zone_name'];

    $out .= "<option value='$zone_id'" . (($zone_id == 1) ? ' selected="selected"' : '') . " >$zone_name</option>\n";
      }
  }
    $out .= "</select>\n";
    return $out;

}



So stimmen nun auch die Alphabetischen Sortierungen
MfG

Peter