PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ab0x
Forum Newbie
Posts: 2 Joined: Mon Oct 09, 2006 4:50 pm
Post
by ab0x » Mon Oct 09, 2006 4:54 pm
OK, so I have a form that changes based on URL parameters. To do this I put the entire form in its own variable. I looks like this at the moment:
Code: Select all
$displayForm = '<form action="'.$formAction.'" method="post" name="editforum" id="editforum">
<h3>Forum category</h3>
<p><select name="category_id">
</select></p>
<h3>Forum name</h3>
<p>What would you like the forum to be called?</p>
<p><input name="forum_name" type="text" id="forum_name" value="'.$row_editForum['forum_name'].'" size="30" maxlength="40"></p>
<h3>Forum description</h3>
<p>A brief description of the forum</p>
<p><input name="forum_description" type="text" id="forum_description" value="'.$row_editForum['forum_description'].'" size="30" maxlength="255"></p>
<h3>Forum position</h3>
<p>Choose the position of the Forum (e.g. 1, 2, 3)</p>
<p><input name="forum_position" type="text" value="'.$row_editForum['forum_position'].'" id="forum_position" size="3" maxlength="3"></p>
<input type="hidden" name="editforum" value="editforum">
<p><input type="submit" name="Submit" value="Submit" class="submit" /></p>
</form>';
The selector (id="category_name") needs to have a list of the categories. Basically I need this code to somehow work in there:
Code: Select all
while($r = mysql_fetch_array($result))
{
echo "<option value=\"". $r['id'] ."\">". $r['title'] ."</option> \n";
}
?>
How do i do this?
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Mon Oct 09, 2006 4:58 pm
Code: Select all
$displayForm = '<form action="'.$formAction.'" method="post" name="editforum" id="editforum">
<h3>Forum category</h3>
<p><select name="category_id">';
while($r = mysql_fetch_array($result))
{
$displayForm .= "<option value=\"". $r['id'] ."\">". $r['title'] ."</option> \n";
}
$displayForm .= '</select></p>
<h3>Forum name</h3>
<p>What would you like the forum to be called?</p>
<p><input name="forum_name" type="text" id="forum_name" value="'.$row_editForum['forum_name'].'" size="30" maxlength="40"></p>
<h3>Forum description</h3>
<p>A brief description of the forum</p>
<p><input name="forum_description" type="text" id="forum_description" value="'.$row_editForum['forum_description'].'" size="30" maxlength="255"></p>
<h3>Forum position</h3>
<p>Choose the position of the Forum (e.g. 1, 2, 3)</p>
<p><input name="forum_position" type="text" value="'.$row_editForum['forum_position'].'" id="forum_position" size="3" maxlength="3"></p>
<input type="hidden" name="editforum" value="editforum">
<p><input type="submit" name="Submit" value="Submit" class="submit" /></p>
</form>';