Jump to content

Weird bug im encountering


HomerTheDragoon

Recommended Posts

Alright, basically I have this drop down box called optone. And when u change the selection of it, it runs a function(which changes other things on the site). The form is for and online gaming league, and they are selecting their matches. It works great when i only have one entry in the database.(one match) However when i add a second match to their database it doesn't run the update on select. So the function doesn't run.

 

Heres the code

<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected">Select a match please</option>
<?$count=0;
$q = mysql_query("SELECT * FROM league_matches WHERE clan1='$clan' or clan2='$clan' ORDER BY weeknum ASC");
while($row = mysql_fetch_array($q))
{
echo '<option value="'.$row['matchid'].'">Week '.$row['weeknum'].': '.$row['clan1'].' vs '.$row['clan2'].'</option>';
}?>
</select>

 

If someone could help me i would greatly apreciate it. Im sure its somthing minor im doing.

Link to comment
Share on other sites

I just tested the HTML since I don't have access to your database. This code seems to work perfectly:

<form name='myform'>
<select name="optone" size="1"
onchange="alert(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected">Select a match please</option>
<option value="1">Week 1: joe vs steve</option>
<option value="2">Week 2: joe vs max</option>
<option value="3">Week 2: mark vs animal</option>
</select>
</form>

 

Try replacing the 'alert()' with the function you're trying to call, and put your PHP while loop back in, then try it and if it still doesn't work I'm guessing your database query is wrong.

 

Hope that helps.

Link to comment
Share on other sites

Sorry for the double post, I fixed it, It happened to be in the function.

 

This is what it was:

<?$q = mysql_query("SELECT * FROM league_matches WHERE clan1='$clan' or clan2='$clan' ORDER BY weeknum ASC");
while($row = mysql_fetch_array($q))
{$q2 = mysql_query("SELECT * FROM league_maps WHERE week='".$row['weeknum']."'");
$row2 = mysql_fetch_array($q2);
?>
if (chosen == "<?echo $row['matchid'];?>") {
<?for($aa=1;$aa<6;$aa++)echo 'map'.$aa.'.src="images/maps/'.$row2['map'.$aa].'";';?>
<?for($a=1;$a<7;$a++)
{
echo "
  selbox".$a.".options[selbox".$a.".options.length] = new Option('".$picked_player[$a][$row['weeknum']]."','".$picked_player[$a][$row['weeknum']]."');
  selbox".$a.".options[selbox".$a.".options.length] = new Option('----------------','".$picked_player[$a][$row['weeknum']]."');";
  for($i=0;$i<$max;$i++)
{echo "
  selbox".$a.".options[selbox".$a.".options.length] = new Option('".$bnet[$i]."','".$bnet[$i]."');";
  }

}
}
?>}

 

And this is what it is now.

<?$q = mysql_query("SELECT * FROM league_matches WHERE clan1='$clan' or clan2='$clan' ORDER BY weeknum ASC");
while($row = mysql_fetch_array($q))
{$q2 = mysql_query("SELECT * FROM league_maps WHERE week='".$row['weeknum']."'");
$row2 = mysql_fetch_array($q2);
?>
if (chosen == "<?echo $row['matchid'];?>") {
<?for($aa=1;$aa<6;$aa++)echo 'map'.$aa.'.src="images/maps/'.$row2['map'.$aa].'";';?>
<?for($a=1;$a<7;$a++)
{
echo "
  selbox".$a.".options[selbox".$a.".options.length] = new Option('".$picked_player[$a][$row['weeknum']]."','".$picked_player[$a][$row['weeknum']]."');
  selbox".$a.".options[selbox".$a.".options.length] = new Option('----------------','".$picked_player[$a][$row['weeknum']]."');";
  for($i=0;$i<$max;$i++)
{echo "
  selbox".$a.".options[selbox".$a.".options.length] = new Option('".$bnet[$i]."','".$bnet[$i]."');";
  }

}?>
[b]}<?
}?>[/b]

 

I closed the javascript if statement inside the php brackets so it thought i was closing the while loop instead :o

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.