I need help guys… When ever someone clicks “edit profile” the language box keeps adding random languages to the profile… each time it seems to add 2x as many and it is adding them in alphabetical order. I know there is something wrong in my code here… but for the life of me I cannot find it. Please let me know if yall see something or if its possibly somewhere else.
This is at the top to pull the info.
[php]
$language_list_array = $_REQUEST[‘language’];
//check langlist//
$checklangQry = mysql_query("select * from profile_languagelist where userid='".$logg_user_id."'");
$checklangCount = mysql_num_rows($checklangQry);
if($checklangCount>0) {
$RemoveLanguages = mysql_query("delete from profile_languagelist where userid='".$logg_user_id."'");
}
foreach($language_list_array as $langvalue)
{
//add//
$rec_user_lang = mysql_query("insert into profile_languagelist(userid,languageid) values('$logg_user_id','$langvalue')");
}
[/php]
This is the code to display in the page.
[php]
<?php
$ReclangQry = mysql_query(“select * from profile_languagelist where userid=’”.$logg_user_id."’");
$ReclangQryCount = mysql_num_rows($ReclangQry);
if($ReclangQryCount>0) {
$langno=0;
while($langdatafetch = mysql_fetch_array($ReclangQry)) {
$langno++;
$languageid = $langdatafetch[‘languageid’];
$languageidarray[] = $langdatafetch[‘languageid’];
?>
<li>
<?php if($langno==1) { ?>
<span>Language</span>
<?php } else { ?>
<span style="border:none;"></span>
<?php } ?>
<?php
$lqry = "select * from languages where id <>''";
if($langno>1) {
$newlang = $langno-1;
for($lno=0;$lno<$newlang;$lno++) {
$lqry .= " and id!='".$languageidarray[$lno]."'";
}
}
?>
<select name="language[]" id="language_<?php echo $langno; ?>">
<?php
$langQry = mysql_query($lqry);
$langQryCount = mysql_num_rows($langQry);
if($langQryCount>0) {
while($langData = mysql_fetch_assoc($langQry)) {
$lang_name = trim($langData['langname']);
$lang_id= trim($langData['id']);
?>
<option value="<?php echo $lang_id; ?>" <?php if($lang_id==$languageid) { ?> selected="selected" <?php } ?>><?php echo $lang_name; ?></option>
<?php } } ?>
</select>
<?php if($langQryCount>1 && $langno==$ReclangQryCount) { ?>
<a href="javascript:;" onclick="ajaxLanguageList('<?php echo $langno; ?>');" id="lang_link_<?php echo $langno; ?>">+ ADD</a>
<?php }?>
</li>
<?php } } else { ?>
<li>
<span>Language 1</span>
<select name="language[]" id="language_1">
<?php
$langQry = mysql_query("select * from languages");
$langQryCount = mysql_num_rows($langQry);
if($langQryCount>0) {
while($langData = mysql_fetch_assoc($langQry)) {
$lang_name = trim($langData['langname']);
$lang_id= trim($langData['id']);
?>
<option value="<?php echo $lang_id; ?>" <?php echo $default; ?>><?php echo $lang_name; ?></option>
<?php } } ?>
</select>
<a href="javascript:;" onclick="ajaxLanguageList('1');" id="lang_link_1">+ ADD</a>
</li>
<?php } ?>
<div id="ajax_language_list">
</div>
[/php]