Page 1 of 1

Submit 2 Variables

Posted: Sat Jul 08, 2006 6:39 pm
by SidewinderX
Here is a piece of my code im working with

Code: Select all

$sql41 = "SELECT * FROM ".$prefix."_theme_authors ORDER BY author ASC";
$result41 = $db->sql_query($sql41);
echo "<form action='index.php' method='get'>
<select name='name'>";
while($row41 = $db->sql_fetchrow($result41)){
echo "<option value='".$row41['author']."'>".$row41['author']."</option>";
}
echo "</select>

<input type='submit' />
</form>";
this submits index.php?name=$author where $author is the author selected, however i want to submit $author and the $default_theme associated with the author so it would look like index.php?name=$author&t=$default_theme but i am unsure how to go about this...i tired

Code: Select all

echo "<option value='".$row41['author']."&t=".$row41['default_theme']."'>".$row41['author']."</option>";
but that didnt work....

I'd guess i have to have a hidden input but i dont know how to have the author I select from the menu associate itself with the default_theme it is pared with.

thank you.

Posted: Sat Jul 08, 2006 6:53 pm
by Nathaniel
Probably the easiest way would be to seperate the two values with a character that is not allowed in either the author's name or the theme's name...

like "value="Joe.default_theme". Then explode() it on the '.'; the first element will be the author's name, the second, the theme.

Posted: Sat Jul 08, 2006 6:53 pm
by Skara
^ seems like the best idea. If not, try using javascript to set a hidden field when the select field is selected.

Posted: Sat Jul 08, 2006 7:36 pm
by Ollie Saunders
If you added a default_theme like that you are getting more than the users input.
If you are adding in the default_theme into the html as you generate the form surely you can use the same process that gets that data to find the default_theme from an author server side.

What I'm saying is, you shouldn't need to do this, ordinarily anyway.