Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: mickinell - toukokuu 01, 2008, 10:21:47 AP

Otsikko: Dropdown appearing multiple times? SOLVED
Kirjoitti: mickinell - toukokuu 01, 2008, 10:21:47 AP
Edit:  I'd delete this if I could.  Caught my mistake.

I cannot figure out what I've done wrong.

Here's the problem.  There are currently three options in my dropdown, so it's displaying THREE dropdowns:

Option One v

Option One v
Option Two

Option One v
Option Two
Option Three

Why is it doing that?  I'm using the same code I've used elsewhere and it hasn't done that!  The relevant code's below.

$result = dbquery("SELECT catid, parentcatid, category, slevel  FROM ".TABLEPREFIX."fanfiction_categories WHERE slevel < 2 AND  parentcatid > -1 ORDER BY parentcatid");
while ($row = mysql_fetch_array($result)) {
$catid = $row['catid'];
$pcat = $row['parentcatid'];
$category = $row['category'];
$slevel = $row['slevel'];
$option_block .= "<option value=\"$catid\">Parent: $pcat -- Category: $category --  Level: $slevel</option>";
$output .= "<FORM METHOD=\"POST\" ACTION=\"admin.php?action=show_editcat\"><P><select name=\"category\">$option_block</select><input type=\"SUBMIT\" NAME=\"submit\" VALUE=\"Edit this category\"></p></form>";
}
Otsikko: Re: Dropdown appearing multiple times? SOLVED
Kirjoitti: Spaceman-Spiff - toukokuu 01, 2008, 01:45:37 IP
You should put $ouput line outside the loop. When you put it inside, what happens is, it prints the form 3 times.